Prepare for GPMC driver conversion
Subsystems (6)
v2 cover Prepare for GPMC driver conversion
Hi,
Objective of this series is to make things easy for GPMC driver conversion series by separating out more things from driver conversion series.
This series,
1. Unifies NAND platform initialization functions
2. Prepares OneNAND platform code for gpmc driver migration
3. Handles additional timings in Kernel
This series is based on 3.5-rc1 & made on top of
[PATCH v2 00/10] Prepare for GPMC driver conversion (w.r.t MTD) {http://www.mail-archive.com/linux-omap at vger.kernel.org/msg70096.html}
These changes has been tested with omap3evm & beagle board. Relevant GPMC peripherals that got tested by this were NAND (beagle) and OneNAND (using local patches for omap3evm)
Hi Jon,
If you can test these changes on boards having NAND it would be really helpful. Tony's remaining concern with this series is whether this would cause NAND filesystem corruption
Regards
Afzal
v2:
1. Make use of timing api for setting clock activation time, and remove direct writing to register for clock activation. Peripherals making use of it were tusb6010 & onenand
2. Move ensuring that async mode in OneNAND has been setup from set_sync to setup function, improve commit message
Afzal Mohammed (3):
ARM: OMAP2+: nand: unify init functions
ARM: OMAP2+: onenand: prepare for gpmc driver migration
ARM: OMAP2+: gpmc: handle additional timings
arch/arm/mach-omap2/board-devkit8000.c | 8 +++-- arch/arm/mach-omap2/board-flash.c | 45 ++++++++++++++------------- arch/arm/mach-omap2/board-flash.h | 6 ++-- arch/arm/mach-omap2/board-igep0020.c | 2 +- arch/arm/mach-omap2/board-ldp.c | 4 +-- arch/arm/mach-omap2/board-omap3beagle.c | 8 +++-- arch/arm/mach-omap2/board-omap3touchbook.c | 8 +++-- arch/arm/mach-omap2/board-overo.c | 7 +++-- arch/arm/mach-omap2/board-zoom.c | 5 +-- arch/arm/mach-omap2/common-board-devices.c | 46 ---------------------------- arch/arm/mach-omap2/common-board-devices.h | 1 - arch/arm/mach-omap2/gpmc-onenand.c | 28 ++++++++--------- arch/arm/mach-omap2/gpmc.c | 6 ++++ arch/arm/mach-omap2/usb-tusb6010.c | 3 +- arch/arm/plat-omap/include/plat/gpmc.h | 6 ++++ 15 files changed, 82 insertions(+), 101 deletions(-)
Signature · 1 line
1.7.10.2
PATCH v2 1/3 ARM: OMAP2+: nand: unify init functions
Helper function for updating nand platform data has been added the capability to take timing structure arguement. Usage of omap_nand_flash_init() has been replaced by modifed one, omap_nand_flash_init was doing things similar to board_nand_init except that NAND CS# were being acquired based on bootloader setting. As CS# is hardwired for a given board, acquiring gpmc CS# has been removed, and updated with the value on board.
NAND CS# used in beagle board was found to be CS0. Thomas Weber <[email protected]> reported that value of devkit8000 to be CS0. Overo board was found to be using CS0 based on u-boot, while google grep says omap3touchbook too has CS0.
--- arch/arm/mach-omap2/board-devkit8000.c | 8 +++-- arch/arm/mach-omap2/board-flash.c | 45 ++++++++++++++------------- arch/arm/mach-omap2/board-flash.h | 6 ++-- arch/arm/mach-omap2/board-igep0020.c | 2 +- arch/arm/mach-omap2/board-ldp.c | 4 +-- arch/arm/mach-omap2/board-omap3beagle.c | 8 +++-- arch/arm/mach-omap2/board-omap3touchbook.c | 8 +++-- arch/arm/mach-omap2/board-overo.c | 7 +++-- arch/arm/mach-omap2/board-zoom.c | 5 +-- arch/arm/mach-omap2/common-board-devices.c | 46 ---------------------------- arch/arm/mach-omap2/common-board-devices.h | 1 - 11 files changed, 56 insertions(+), 84 deletions(-)
arch/arm/mach-omap2/board-devkit8000.c +6 -2
@@ -59,8 +59,11 @@#include "mux.h" #include "hsmmc.h" +#include "board-flash.h" #include "common-board-devices.h" +#define NAND_CS 0 +#define OMAP_DM9000_GPIO_IRQ 25#define OMAP3_DEVKIT_TS_GPIO 27
@@ -628,8 +631,9 @@ static void __init devkit8000_init(void)usb_musb_init (NULL );usbhs_init (&usbhs_bdata); -omap_nand_flash_init (NAND_BUSWIDTH_16 , devkit8000_nand_partitions, -ARRAY_SIZE (devkit8000_nand_partitions)); +board_nand_init (devkit8000_nand_partitions, +ARRAY_SIZE (devkit8000_nand_partitions),NAND_CS , +NAND_BUSWIDTH_16 ,NULL );/* Ensure SDRC pins are mux'd for self-refresh */ omap_mux_init_signal ("sdrc_cke0" ,OMAP_PIN_OUTPUT );
arch/arm/mach-omap2/board-flash.c +23 -22
69 lines not on this page · raw message
arch/arm/mach-omap2/board-flash.h +4 -2
@@ -40,12 +40,14 @@ static inline void board_flash_init(struct flash_partitions part[],#if defined(CONFIG_MTD_NAND_OMAP2 ) || \ defined(CONFIG_MTD_NAND_OMAP2_MODULE )extern void board_nand_init (struct mtd_partition *nand_parts, -u8 nr_parts,u8 cs,int nand_type); +u8 nr_parts,u8 cs,int nand_type,struct gpmc_timings *gpmc_t); +extern struct gpmc_timings nand_default_timings[];#else static inline void board_nand_init (struct mtd_partition *nand_parts, -u8 nr_parts,u8 cs,int nand_type) +u8 nr_parts,u8 cs,int nand_type,struct gpmc_timings *gpmc_t) { } +#define nand_default_timings NULL#endif #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
arch/arm/mach-omap2/board-igep0020.c +1 -1
@@ -175,7 +175,7 @@ static void __init igep_flash_init(void)pr_info ("IGEP: initializing NAND memory device\n" );board_nand_init (igep_flash_partitions,ARRAY_SIZE (igep_flash_partitions), -0 ,NAND_BUSWIDTH_16 ); +0 ,NAND_BUSWIDTH_16 , nand_default_timings); }else if (mux ==IGEP_SYSBOOT_ONENAND ) {pr_info ("IGEP: initializing OneNAND memory device\n" ); board_onenand_init(igep_flash_partitions,
arch/arm/mach-omap2/board-ldp.c +2 -2
@@ -427,8 +427,8 @@ static void __init omap_ldp_init(void)omap_serial_init ();omap_sdrc_init (NULL ,NULL );usb_musb_init (NULL ); -board_nand_init (ldp_nand_partitions, -ARRAY_SIZE (ldp_nand_partitions),ZOOM_NAND_CS ,0 ); +board_nand_init (ldp_nand_partitions,ARRAY_SIZE (ldp_nand_partitions), +ZOOM_NAND_CS ,0 , nand_default_timings);omap_hsmmc_init (mmc);ldp_display_init ();
arch/arm/mach-omap2/board-omap3beagle.c +6 -2
@@ -51,8 +51,11 @@#include "mux.h" #include "hsmmc.h" #include "pm.h" +#include "board-flash.h" #include "common-board-devices.h" +#define NAND_CS 0 +/* * OMAP3 Beagle revision * Run time detection of Beagle revision is done by reading GPIO.
@@ -521,8 +524,9 @@ static void __init omap3_beagle_init(void)usb_musb_init (NULL );usbhs_init (&usbhs_bdata); -omap_nand_flash_init (NAND_BUSWIDTH_16 , omap3beagle_nand_partitions, -ARRAY_SIZE (omap3beagle_nand_partitions)); +board_nand_init (omap3beagle_nand_partitions, +ARRAY_SIZE (omap3beagle_nand_partitions),NAND_CS , +NAND_BUSWIDTH_16 ,NULL );/* Ensure msecure is mux'd to be able to set the RTC. */ omap_mux_init_signal ("sys_drm_msecure" ,OMAP_PIN_OFF_OUTPUT_HIGH );
arch/arm/mach-omap2/board-omap3touchbook.c +6 -2
@@ -52,6 +52,7 @@#include "mux.h" #include "hsmmc.h" +#include "board-flash.h" #include "common-board-devices.h" #include <asm/setup.h>
@@ -61,6 +62,8 @@#define TB_BL_PWM_TIMER 9#define TB_KILL_POWER_GPIO 168 +#define NAND_CS 0 +static unsigned long touchbook_revision;static struct mtd_partition omap3touchbook_nand_partitions[] = {
@@ -370,8 +373,9 @@ static void __init omap3_touchbook_init(void)omap_ads7846_init (4 ,OMAP3_TS_GPIO ,310 , &ads7846_pdata);usb_musb_init (NULL );usbhs_init (&usbhs_bdata); -omap_nand_flash_init (NAND_BUSWIDTH_16 , omap3touchbook_nand_partitions, -ARRAY_SIZE (omap3touchbook_nand_partitions)); +board_nand_init (omap3touchbook_nand_partitions, +ARRAY_SIZE (omap3touchbook_nand_partitions),NAND_CS , +NAND_BUSWIDTH_16 ,NULL );/* Ensure SDRC pins are mux'd for self-refresh */ omap_mux_init_signal ("sdrc_cke0" ,OMAP_PIN_OUTPUT );
arch/arm/mach-omap2/board-overo.c +5 -2
@@ -57,8 +57,11 @@#include "mux.h" #include "sdram-micron-mt46h32m32lf-6.h" #include "hsmmc.h" +#include "board-flash.h" #include "common-board-devices.h" +#define NAND_CS 0 +#define OVERO_GPIO_BT_XGATE 15#define OVERO_GPIO_W2W_NRESET 16#define OVERO_GPIO_PENDOWN 114
@@ -500,8 +503,8 @@ static void __init overo_init(void)omap_serial_init ();omap_sdrc_init (mt46h32m32lf6_sdrc_params, mt46h32m32lf6_sdrc_params); -omap_nand_flash_init (0 , overo_nand_partitions, -ARRAY_SIZE (overo_nand_partitions)); +board_nand_init (overo_nand_partitions, +ARRAY_SIZE (overo_nand_partitions),NAND_CS ,0 ,NULL );usb_musb_init (NULL );usbhs_init (&usbhs_bdata);overo_spi_init ();
arch/arm/mach-omap2/board-zoom.c +3 -2
@@ -114,8 +114,9 @@ static void __init omap_zoom_init(void)usbhs_init (&usbhs_bdata); } -board_nand_init (zoom_nand_partitions,ARRAY_SIZE (zoom_nand_partitions), -ZOOM_NAND_CS ,NAND_BUSWIDTH_16 ); +board_nand_init (zoom_nand_partitions, +ARRAY_SIZE (zoom_nand_partitions),ZOOM_NAND_CS , +NAND_BUSWIDTH_16 , nand_default_timings);zoom_debugboard_init ();zoom_peripherals_init ();
arch/arm/mach-omap2/common-board-devices.c +0 -46
49 lines not on this page · raw message
arch/arm/mach-omap2/common-board-devices.h +0 -1
@@ -10,6 +10,5 @@ struct ads7846_platform_data;void omap_ads7846_init (int bus_num,int gpio_pendown,int gpio_debounce,struct ads7846_platform_data *board_pdata); -void omap_nand_flash_init (int opts,struct mtd_partition *parts,int n_parts);#endif /* __OMAP_COMMON_BOARD_DEVICES__ */
Signature · 1 line
1.7.10.2
PATCH v2 2/3 ARM: OMAP2+: onenand: prepare for gpmc driver migration
In reply to Afzal MohammedReorganize gpmc-onenand initialization so that changes required for gpmc driver migration can be made smooth.
Ensuring sync read/write are disabled in onenand cannot be expected to work properly unless GPMC is setup, this has been removed. And invocation of set_async has been moved from set_sync to gpmc_onenand_init function; gpmc for onenand needs to be initialized to async mode (even for sync mode initially). Ensuring that onenand part has been setup for async mode has been moved now to setup function.
Thanks to Jon for his suggestions on improving this change.
---
v2: Move ensuring that async mode in OneNAND has been setup from
set_sync to setup function, improve commit message
arch/arm/mach-omap2/gpmc-onenand.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-)
arch/arm/mach-omap2/gpmc-onenand.c +10 -15
@@ -38,10 +38,9 @@ static struct platform_device gpmc_onenand_device = { .resource = &gpmc_onenand_resource, }; -static int omap2_onenand_set_async_mode (int cs,void __iomem *onenand_base) +static int omap2_onenand_set_async_mode (int cs) {struct gpmc_timings t; -u32 reg;int err;const int t_cer =15 ;
@@ -55,11 +54,6 @@ static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base)const int t_wpl =40 ;const int t_wph =30 ; -/* Ensure sync read and sync write are disabled */ - reg =readw (onenand_base +ONENAND_REG_SYS_CFG1 ); - reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE ; -writew (reg, onenand_base +ONENAND_REG_SYS_CFG1 ); -memset (&t,0 ,sizeof (t)); t.sync_clk =0 ; t.cs_on =0 ;
@@ -95,10 +89,6 @@ static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base)if (err)return err; -/* Ensure sync read and sync write are disabled */ - reg =readw (onenand_base +ONENAND_REG_SYS_CFG1 ); - reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE ; -writew (reg, onenand_base +ONENAND_REG_SYS_CFG1 );return 0 ; }
@@ -197,13 +187,10 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg, sync_read =1 ; sync_write =1 ; }else -return omap2_onenand_set_async_mode (cs, onenand_base); +return 0 ;if (!freq) {/* Very first call freq is not known */ - err =omap2_onenand_set_async_mode (cs, onenand_base); -if (err) -return err; freq =omap2_onenand_get_freq (cfg, onenand_base, &clk_dep); first_time =1 ; }
@@ -385,6 +372,12 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg,static int gpmc_onenand_setup (void __iomem *onenand_base,int *freq_ptr) {struct device *dev = &gpmc_onenand_device.dev; +u32 reg; + +/* Ensure sync read and sync write are disabled */ + reg =readw (onenand_base +ONENAND_REG_SYS_CFG1 ); + reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE ; +writew (reg, onenand_base +ONENAND_REG_SYS_CFG1 );/* Set sync timings in GPMC */ if (omap2_onenand_set_sync_mode(gpmc_onenand_data, onenand_base,
@@ -421,6 +414,8 @@ void __init gpmc_onenand_init(struct omap_onenand_platform_data *_onenand_data) gpmc_onenand_resource.end = gpmc_onenand_resource.start +ONENAND_IO_SIZE -1 ; +omap2_onenand_set_async_mode (gpmc_onenand_data->cs); +if (platform_device_register (&gpmc_onenand_device) <0 ) {pr_err ("%s: Unable to register OneNAND device\n" , __func__);gpmc_cs_free (gpmc_onenand_data->cs);
Signature · 1 line
1.7.10.2
PATCH v2 2/3 ARM: OMAP2+: onenand: prepare for gpmc driver migration
Hi Afzal,
Thanks for sending the update.
Quoted 52 lines · Afzal Mohammed
Reorganize gpmc-onenand initialization so that changes required for gpmc driver migration can be made smooth.
Ensuring sync read/write are disabled in onenand cannot be expected to work properly unless GPMC is setup, this has been removed. And invocation of
set_asynchas been moved fromset_synctogpmc_onenand_initfunction; gpmc for onenand needs to be initialized to async mode (even for sync mode initially). Ensuring that onenand part has been setup for async mode has been moved now to setup function.Thanks to Jon for his suggestions on improving this change.
Signed-off-by Afzal Mohammed <[email protected]>---
v2: Move ensuring that async mode in OneNAND has been setup from
set_syncto setup function, improve commit messagearch/arm/mach-omap2/gpmc-onenand.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-)arch/arm/mach-omap2/gpmc-onenand.c +1
-7@@ -38,10 +38,9 @@ static struct platform_device gpmc_onenand_device = { .resource = &gpmc_onenand_resource, }; -static int omap2_onenand_set_async_mode (int cs,void __iomem *onenand_base) +static int omap2_onenand_set_async_mode (int cs) {struct gpmc_timings t; -u32 reg;int err;const int t_cer =15 ;@@ -55,11 +54,6 @@ static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base)const int t_wpl =40 ;const int t_wph =30 ; -/* Ensure sync read and sync write are disabled */ - reg =readw (onenand_base +ONENAND_REG_SYS_CFG1 ); - reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE ; -writew (reg, onenand_base +ONENAND_REG_SYS_CFG1 ); -memset (&t,0 ,sizeof (t)); t.sync_clk =0 ; t.cs_on =0 ;
arch/arm/mach-omap2/gpmc-onenand.c static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base) · line 101
Quoted 7 lines
arch/arm/mach-omap2/gpmc-onenand.c +0
-4@@ -95,10 +89,6 @@ static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base)if (err)return err; -/* Ensure sync read and sync write are disabled */ - reg =readw (onenand_base +ONENAND_REG_SYS_CFG1 ); - reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE ; -writew (reg, onenand_base +ONENAND_REG_SYS_CFG1 );
Sorry if I was not clear, but I was still thinking that we keep the above instance of setting async mode.
Quoted 18 lines
arch/arm/mach-omap2/gpmc-onenand.c +1
-4return 0 ; }@@ -197,13 +187,10 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg, sync_read =1 ; sync_write =1 ; }else -return omap2_onenand_set_async_mode (cs, onenand_base); +return 0 ;if (!freq) {/* Very first call freq is not known */ - err =omap2_onenand_set_async_mode (cs, onenand_base); -if (err) -return err; freq =omap2_onenand_get_freq (cfg, onenand_base, &clk_dep); first_time =1 ; }
arch/arm/mach-omap2/gpmc-onenand.c static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg, · line 380
Quoted 9 lines
arch/arm/mach-omap2/gpmc-onenand.c +6
-0@@ -385,6 +372,12 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg,static int gpmc_onenand_setup (void __iomem *onenand_base,int *freq_ptr) {struct device *dev = &gpmc_onenand_device.dev; +u32 reg; + +/* Ensure sync read and sync write are disabled */ + reg =readw (onenand_base +ONENAND_REG_SYS_CFG1 ); + reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE ; +writew (reg, onenand_base +ONENAND_REG_SYS_CFG1 );
... and here we should just call omap2_onenand_set_async_mode(), ...
arch/arm/mach-omap2/gpmc-onenand.c void __init gpmc_onenand_init(struct omap_onenand_platform_data *_onenand_data) · line 418
Quoted 8 lines
arch/arm/mach-omap2/gpmc-onenand.c +2
-0/* Set sync timings in GPMC */ if (omap2_onenand_set_sync_mode(gpmc_onenand_data, onenand_base,@@ -421,6 +414,8 @@ void __init gpmc_onenand_init(struct omap_onenand_platform_data *_onenand_data) gpmc_onenand_resource.end = gpmc_onenand_resource.start +ONENAND_IO_SIZE -1 ; +omap2_onenand_set_async_mode (gpmc_onenand_data->cs); +
... then remove the above call.
Cheers
Jon
PATCH v2 2/3 ARM: OMAP2+: onenand: prepare for gpmc driver migration
Hi Jon,
Quoted 11 lines · Jon
arch/arm/mach-omap2/gpmc-onenand.c static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base) · line 101
Quoted 8 lines
arch/arm/mach-omap2/gpmc-onenand.c +0
-4@@ -95,10 +89,6 @@ static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base)if (err)return err; -/* Ensure sync read and sync write are disabled */ - reg =readw (onenand_base +ONENAND_REG_SYS_CFG1 ); - reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE ; -writew (reg, onenand_base +ONENAND_REG_SYS_CFG1 );Sorry if I was not clear, but I was still thinking that we keep the above instance of setting async mode.
:
Quoted 11 lines
arch/arm/mach-omap2/gpmc-onenand.c static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg, · line 380
Quoted 9 lines
arch/arm/mach-omap2/gpmc-onenand.c +6
-0static int gpmc_onenand_setup (void __iomem *onenand_base,int *freq_ptr) {struct device *dev = &gpmc_onenand_device.dev; +u32 reg; + +/* Ensure sync read and sync write are disabled */ + reg =readw (onenand_base +ONENAND_REG_SYS_CFG1 ); + reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE ; +writew (reg, onenand_base +ONENAND_REG_SYS_CFG1 );... and here we should just call
omap2_onenand_set_async_mode(), ...
If omap2_onenand_set_async_mode is called from gpmc_onenand_setup & removed from gpmc_onenand_init, when using new gpmc driver interface, i.e. using gpmc_onenand_update [1], we lost opportunity to provide gpmc driver with configuration details for async mode causing a big warning about each timings & configurations that was left by bootloader (which is meant only for cases where Kernel can't configure GPMC). Of course, we can put omap2_onenand_set_async_mode in gpmc_onenand_update too, but then unnecessarily, omap2_onenand_sey_async_mode would be called twice.
Please note that gpmc_onenand_setup is a callback by onenand driver.
Regards
Afzal
Quoted 5 lines
arch/arm/mach-omap2/gpmc-onenand.c void __init gpmc_onenand_init(struct omap_onenand_platform_data *_onenand_data) · line 418
Quoted 3 lines
arch/arm/mach-omap2/gpmc-onenand.c +2
-0+omap2_onenand_set_async_mode (gpmc_onenand_data->cs); +... then remove the above call.
[1] http://www.mail-archive.com/linux-omap at vger.kernel.org/msg69919.html
PATCH v2 2/3 ARM: OMAP2+: onenand: prepare for gpmc driver migration
Hi Afzal,
Quoted 37 lines · Afzal
Hi Jon,
Quoted 11 lines · Jon
arch/arm/mach-omap2/gpmc-onenand.c static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base) · line 101
Quoted 8 lines
arch/arm/mach-omap2/gpmc-onenand.c +0
-4@@ -95,10 +89,6 @@ static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base)if (err)return err; -/* Ensure sync read and sync write are disabled */ - reg =readw (onenand_base +ONENAND_REG_SYS_CFG1 ); - reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE ; -writew (reg, onenand_base +ONENAND_REG_SYS_CFG1 );Sorry if I was not clear, but I was still thinking that we keep the above instance of setting async mode.
:
Quoted 11 lines
arch/arm/mach-omap2/gpmc-onenand.c static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg, · line 380
Quoted 9 lines
arch/arm/mach-omap2/gpmc-onenand.c +6
-0static int gpmc_onenand_setup (void __iomem *onenand_base,int *freq_ptr) {struct device *dev = &gpmc_onenand_device.dev; +u32 reg; + +/* Ensure sync read and sync write are disabled */ + reg =readw (onenand_base +ONENAND_REG_SYS_CFG1 ); + reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE ; +writew (reg, onenand_base +ONENAND_REG_SYS_CFG1 );... and here we should just call
omap2_onenand_set_async_mode(), ...If
omap2_onenand_set_async_modeis called fromgpmc_onenand_setup& removed fromgpmc_onenand_init, when using new gpmc driver interface, i.e. usinggpmc_onenand_update[1], we lost opportunity to provide gpmc driver with configuration details for async mode causing a big warning about each timings & configurations that was left by bootloader (which is meant only for cases where Kernel can't configure GPMC). Of course, we can putomap2_onenand_set_async_modeingpmc_onenand_updatetoo, but then unnecessarily,omap2_onenand_sey_async_modewould be called twice.
Quoted 1 line
Please note that
gpmc_onenand_setupis a callback by onenand driver.
Ok, I see your point. So today the _set_async_mode() is really doing two things ...
1. It is calculating the timings
2. Programming the timings and setting async mode.
I think that it would be best if we were to make _set_async_mode() into two functions, for example ...
1. omap2_onenand_get_async_timings()
2. omap2_onenand_set_async_timings()
Where the omap2_onenand_get_async_timings() calculates the timings and can be used in both legacy mode and with the driver. Then omap2_onenand_set_sync_timings() is just used in the legacy mode where we don't have the driver to configure the chip-select.
Do you think that could work?
We could also do the same for omap2_onenand_set_sync_mode().
Cheers
Jon
PATCH v2 2/3 ARM: OMAP2+: onenand: prepare for gpmc driver migration
Hi Jon,
Quoted 12 lines · Jon
Ok, I see your point. So today the
_set_async_mode()is really doing two things ...1. It is calculating the timings
2. Programming the timings and setting async mode.I think that it would be best if we were to make
_set_async_mode()into two functions, for example ...1.
omap2_onenand_get_async_timings()
2.omap2_onenand_set_async_timings()
Quoted 8 lines
Where the
omap2_onenand_get_async_timings()calculates the timings and can be used in both legacy mode and with the driver. Thenomap2_onenand_set_sync_timings()is just used in the legacy mode where we don't have the driver to configure the chip-select.Do you think that could work?
We could also do the same for
omap2_onenand_set_sync_mode().
Seems it should work
Not sure whether the best time to do such kind of refactoring is at the time of cleaning up / generalizing timing calculation, one reason to think that way being removal of legacy mode once driver migration is completed. Goal for this series was to do the minimal of changes, without creating any disruptive changes to prepare for gpmc driver series so that both interfaces would work.
Either way I will go ahead and make change as per your suggestions, seems at least there is one advantage; w.r.t bringing setting bool type time settings to gpmc_cs_set_timings (even though may not be necessary for this change, it will certainly simplify it) and make it part of driver preparation series and this will help us discover if any board depends on these kinds of settings unknowingly with the preparation series itself rather than hunting for it in driver series
Regards
Afzal
PATCH v2 3/3 ARM: OMAP2+: gpmc: handle additional timings
In reply to Afzal MohammedConfigure busturnaround, cycle2cycledelay, waitmonitoringtime, clkactivationtime in gpmc_cs_set_timings(). This is done so that boards can configure these parameters of gpmc in Kernel instead of relying on bootloader.
This needed change to two existing users that were configuring clk activation time by directly writing to registers. Thanks to Tony for making me aware of the issue & being kind enough to test this change.
---
v2: Make use of timings api for setting clock activation time, and
remove direct writing to register for clock activation. Peripherals making use of it were tusb6010 & onenand
arch/arm/mach-omap2/gpmc-onenand.c | 3 ++- arch/arm/mach-omap2/gpmc.c | 6 ++++++ arch/arm/mach-omap2/usb-tusb6010.c | 3 ++- arch/arm/plat-omap/include/plat/gpmc.h | 6 ++++++ 4 files changed, 16 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/gpmc-onenand.c +2 -1
@@ -316,6 +316,8 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg, t.rd_cycle =gpmc_ticks_to_ns (fclk_offset + (latency +1 ) * div + ticks_cez); + t.clk_activation = fclk_offset_ns; +/* Write */ if (sync_write) { t.adv_wr_off = t.adv_rd_off;
@@ -349,7 +351,6 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg, (sync_read ?GPMC_CONFIG1_READTYPE_SYNC :0 ) | (sync_write ?GPMC_CONFIG1_WRITEMULTIPLE_SUPP :0 ) | (sync_write ?GPMC_CONFIG1_WRITETYPE_SYNC :0 ) | -GPMC_CONFIG1_CLKACTIVATIONTIME (fclk_offset) | GPMC_CONFIG1_PAGE_LEN(2) | (cpu_is_omap34xx() ? 0 : (GPMC_CONFIG1_WAIT_READ_MON |
arch/arm/mach-omap2/gpmc.c +6 -0
@@ -313,6 +313,12 @@ int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t)GPMC_SET_ONE (GPMC_CS_CONFIG5 ,24 ,27 , page_burst_access); +GPMC_SET_ONE (GPMC_CS_CONFIG6 ,0 ,3 , bus_turnaround); +GPMC_SET_ONE (GPMC_CS_CONFIG6 ,8 ,11 , cycle2cycle_delay); + +GPMC_SET_ONE (GPMC_CS_CONFIG1 ,18 ,19 , wait_monitoring); +GPMC_SET_ONE (GPMC_CS_CONFIG1 ,25 ,26 , clk_activation); +if (cpu_is_omap34xx ()) {GPMC_SET_ONE (GPMC_CS_CONFIG6 ,16 ,19 , wr_data_mux_bus);GPMC_SET_ONE (GPMC_CS_CONFIG6 ,24 ,28 , wr_access);
arch/arm/mach-omap2/usb-tusb6010.c +2 -1
@@ -174,6 +174,8 @@ static int tusb_set_sync_mode(unsigned sysclk_ps, unsigned fclk_ps) tmp = t.cs_wr_off *1000 +7000 /* t_scsn_rdy_z */ ; t.wr_cycle =next_clk (t.cs_wr_off, tmp, fclk_ps); + t.clk_activation =gpmc_ticks_to_ns (1 ); +return gpmc_cs_set_timings (sync_cs, &t); }
@@ -283,7 +285,6 @@ tusb6010_setup_interface(struct musb_hdrc_platform_data *data, | GPMC_CONFIG1_READTYPE_SYNC |GPMC_CONFIG1_WRITEMULTIPLE_SUPP |GPMC_CONFIG1_WRITETYPE_SYNC - |GPMC_CONFIG1_CLKACTIVATIONTIME (1 ) |GPMC_CONFIG1_PAGE_LEN (2 ) |GPMC_CONFIG1_WAIT_READ_MON |GPMC_CONFIG1_WAIT_WRITE_MON
arch/arm/plat-omap/include/plat/gpmc.h +6 -0
@@ -128,6 +128,12 @@ struct gpmc_timings {u16 rd_cycle;/* Total read cycle time */ u16 wr_cycle;/* Total write cycle time */ +u16 bus_turnaround; +u16 cycle2cycle_delay; + +u16 wait_monitoring; +u16 clk_activation; +/* The following are only on OMAP3430 */ u16 wr_access;/* WRACCESSTIME */ u16 wr_data_mux_bus;/* WRDATAONADMUXBUS */
Signature · 1 line
1.7.10.2