add gpmi support for imx6q
Subsystems (6)
v3 cover add gpmi support for imx6q
This patch set adds the gpmi-nand support for imx6q.
I prefer to add the clocks in the gpmi-nand driver.
Yes, it will change the gpmi nand driver, but we have to do so. The reason is :
We will support the ONFI nand in mx6q in the future. If the ONFI nand is set to Sync mode, we have to __change__ the clocks explicitly.
Test this patch set on imx6q-arm2 board.
v2 --> v3:
[1] fix a bug the clocks.
v1 --> v2:
[1] add dev_id for the gpmi-nand's clocks.
[2] set the default values for these clocks.
Huang Shijie (3):
ARM: imx6q: add clocks for gpmi-nand
ARM: imx6q: add DT node for gpmi nand
mtd: gpmi: change the code for clocks
arch/arm/boot/dts/imx6q-arm2.dts | 6 ++ arch/arm/boot/dts/imx6q.dtsi | 36 ++++++++++++++ arch/arm/mach-imx/clk-imx6q.c | 8 +++- drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 43 ++++++++++++++--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 82 ++++++++++++++++++++++++++++---- drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 3 +- 6 files changed, 159 insertions(+), 19 deletions(-)
Signature · 1 line
1.7.4.4
PATCH v3 1/3 ARM: imx6q: add clocks for gpmi-nand
Add clocks for gpmi-nand.
--- arch/arm/mach-imx/clk-imx6q.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
arch/arm/mach-imx/clk-imx6q.c +7 -1
@@ -151,7 +151,7 @@ enum mx6q_clks { esai, gpt_ipg, gpt_ipg_per, gpu2d_core, gpu3d_core, hdmi_iahb, hdmi_isfr, i2c1, i2c2, i2c3, iim, enfc, ipu1, ipu1_di0, ipu1_di1, ipu2, ipu2_di0, ldb_di0, ldb_di1, ipu2_di1, hsi_tx, mlb, mmdc_ch0_axi, - mmdc_ch1_axi, ocram, openvg_axi, pcie_axi, pwm1, pwm2, pwm3, pwm4, + mmdc_ch1_axi, ocram, openvg_axi, pcie_axi, pwm1, pwm2, pwm3, pwm4, per1_bch, gpmi_bch_apb, gpmi_bch, gpmi_io, gpmi_apb, sata, sdma, spba, ssi1, ssi2, ssi3, uart_ipg, uart_serial, usboh3, usdhc1, usdhc2, usdhc3, usdhc4, vdo_axi, vpu_axi, cko1, pll1_sys, pll2_bus, pll3_usb_otg,
@@ -357,6 +357,7 @@ int __init mx6q_clocks_init(void) clk[ocram] =imx_clk_gate2 ("ocram" ,"ahb" , base +0x74 ,28 ); clk[openvg_axi] =imx_clk_gate2 ("openvg_axi" ,"axi" , base +0x74 ,30 ); clk[pcie_axi] =imx_clk_gate2 ("pcie_axi" ,"pcie_axi_sel" , base +0x78 ,0 ); + clk[per1_bch] =imx_clk_gate2 ("per1_bch" ,"usdhc3" , base +0x78 ,12 ); clk[pwm1] =imx_clk_gate2 ("pwm1" ,"ipg_per" , base +0x78 ,16 ); clk[pwm2] =imx_clk_gate2 ("pwm2" ,"ipg_per" , base +0x78 ,18 ); clk[pwm3] =imx_clk_gate2 ("pwm3" ,"ipg_per" , base +0x78 ,20 );
@@ -394,6 +395,11 @@ int __init mx6q_clocks_init(void)clk_register_clkdev (clk[twd],NULL ,"smp_twd" );clk_register_clkdev (clk[usboh3],NULL ,"usboh3" );clk_register_clkdev (clk[apbh_dma],NULL ,"110000.dma-apbh" ); +clk_register_clkdev (clk[per1_bch],"per1_bch" ,"112000.gpmi-nand" ); +clk_register_clkdev (clk[gpmi_bch_apb],"gpmi_bch_apb" ,"112000.gpmi-nand" ); +clk_register_clkdev (clk[gpmi_bch],"gpmi_bch" ,"112000.gpmi-nand" ); +clk_register_clkdev (clk[gpmi_apb],"gpmi_apb" ,"112000.gpmi-nand" ); +clk_register_clkdev (clk[gpmi_io],NULL ,"112000.gpmi-nand" );clk_register_clkdev (clk[uart_serial],"per" ,"2020000.serial" );clk_register_clkdev (clk[uart_ipg],"ipg" ,"2020000.serial" );clk_register_clkdev (clk[uart_serial],"per" ,"21e8000.serial" );
Signature · 1 line
1.7.4.4
PATCH v3 1/3 ARM: imx6q: add clocks for gpmi-nand
Quoted 29 lines · Huang Shijie
Add clocks for gpmi-nand.
Signed-off-by Huang Shijie <[email protected]>--- arch/arm/mach-imx/clk-imx6q.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)arch/arm/mach-imx/clk-imx6q.c +2
-1@@ -151,7 +151,7 @@ enum mx6q_clks { esai, gpt_ipg, gpt_ipg_per, gpu2d_core, gpu3d_core, hdmi_iahb, hdmi_isfr, i2c1, i2c2, i2c3, iim, enfc, ipu1, ipu1_di0, ipu1_di1, ipu2, ipu2_di0, ldb_di0, ldb_di1, ipu2_di1, hsi_tx, mlb, mmdc_ch0_axi, - mmdc_ch1_axi, ocram, openvg_axi, pcie_axi, pwm1, pwm2, pwm3, pwm4, + mmdc_ch1_axi, ocram, openvg_axi, pcie_axi, pwm1, pwm2, pwm3, pwm4, per1_bch, gpmi_bch_apb, gpmi_bch, gpmi_io, gpmi_apb, sata, sdma, spba, ssi1, ssi2, ssi3, uart_ipg, uart_serial, usboh3, usdhc1, usdhc2, usdhc3, usdhc4, vdo_axi, vpu_axi, cko1, pll1_sys, pll2_bus, pll3_usb_otg,@@ -357,6 +357,7 @@ int __init mx6q_clocks_init(void) clk[ocram] =imx_clk_gate2 ("ocram" ,"ahb" , base +0x74 ,28 ); clk[openvg_axi] =imx_clk_gate2 ("openvg_axi" ,"axi" , base +0x74 ,30 ); clk[pcie_axi] =imx_clk_gate2 ("pcie_axi" ,"pcie_axi_sel" , base +0x78 ,0 ); + clk[per1_bch] =imx_clk_gate2 ("per1_bch" ,"usdhc3" , base +0x78 ,12 ); clk[pwm1] =imx_clk_gate2 ("pwm1" ,"ipg_per" , base +0x78 ,16 ); clk[pwm2] =imx_clk_gate2 ("pwm2" ,"ipg_per" , base +0x78 ,18 ); clk[pwm3] =imx_clk_gate2 ("pwm3" ,"ipg_per" , base +0x78 ,20 );
arch/arm/mach-imx/clk-imx6q.c int __init mx6q_clocks_init(void) · line 402
Quoted 8 lines
arch/arm/mach-imx/clk-imx6q.c +5
-0@@ -394,6 +395,11 @@ int __init mx6q_clocks_init(void)clk_register_clkdev (clk[twd],NULL ,"smp_twd" );clk_register_clkdev (clk[usboh3],NULL ,"usboh3" );clk_register_clkdev (clk[apbh_dma],NULL ,"110000.dma-apbh" ); +clk_register_clkdev (clk[per1_bch],"per1_bch" ,"112000.gpmi-nand" ); +clk_register_clkdev (clk[gpmi_bch_apb],"gpmi_bch_apb" ,"112000.gpmi-nand" ); +clk_register_clkdev (clk[gpmi_bch],"gpmi_bch" ,"112000.gpmi-nand" ); +clk_register_clkdev (clk[gpmi_apb],"gpmi_apb" ,"112000.gpmi-nand" ); +clk_register_clkdev (clk[gpmi_io],NULL ,"112000.gpmi-nand" );
It's a little bit strange to me that this clock still gets NULL con_id while all other gpmi-nand clocks have proper con_id assigned.
Quoted 6 lines
arch/arm/mach-imx/clk-imx6q.c +0
-0clk_register_clkdev (clk[uart_serial],"per" ,"2020000.serial" );clk_register_clkdev (clk[uart_ipg],"ipg" ,"2020000.serial" );clk_register_clkdev (clk[uart_serial],"per" ,"21e8000.serial" );Signature · 1 line
1.7.4.4
Signature · 2 lines
Regards, Shawn
PATCH v3 1/3 ARM: imx6q: add clocks for gpmi-nand
? 2012?07?02? 10:10, Shawn Guo ??:
Quoted 3 lines
It's a little bit strange to me that this clock still gets NULL
con_idwhile all other gpmi-nand clocks have propercon_idassigned.
I will fix it in the next version.
thanks
Huang Shijie
PATCH v3 2/3 ARM: imx6q: add DT node for gpmi nand
In reply to Huang ShijieAdd the DT node for gpmi nand.
Add the pinmux support for gpmi nand.
The gpmi nand may conflicts with other modules, such as MMC. So we do not enable the gpmi nand for mx6q-arm2 board, just add the node for the board.
--- arch/arm/boot/dts/imx6q-arm2.dts | 6 ++++++ arch/arm/boot/dts/imx6q.dtsi | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 0 deletions(-)
arch/arm/boot/dts/imx6q-arm2.dts +6 -0
@@ -22,6 +22,12 @@ }; soc { + gpmi-nand at 00112000 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_gpmi_nand_1>; + status = "disabled"; /* gpmi nand conflicts with SD */ + }; + aips-bus at 02100000 { /* AIPS2 */ ethernet at 02188000 { phy-mode = "rgmii";
arch/arm/boot/dts/imx6q.dtsi +36 -0
@@ -92,6 +92,18 @@ reg = <0x00110000 0x2000>; }; + gpmi-nand at 00112000 { + compatible = "fsl,imx6q-gpmi-nand"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x00112000 0x2000>, <0x00114000 0x2000>; + reg-names = "gpmi-nand", "bch"; + interrupts = <0 13 0x04>, <0 15 0x04>; + interrupt-names = "gpmi-dma", "bch"; + fsl,gpmi-dma-channel = <0>; + status = "disabled"; + }; + timer at 00a00600 { compatible = "arm,cortex-a9-twd-timer"; reg = <0x00a00600 0x20>;
@@ -500,6 +512,30 @@ }; }; + gpmi-nand { + pinctrl_gpmi_nand_1: gpmi-nand-1 { + fsl,pins = <1328 0xb0b1 /* MX6Q_PAD_NANDF_CLE__RAWNAND_CLE */ + 1336 0xb0b1 /* MX6Q_PAD_NANDF_ALE__RAWNAND_ALE */ + 1344 0xb0b1 /* MX6Q_PAD_NANDF_WP_B__RAWNAND_RESETN */ + 1352 0xb000 /* MX6Q_PAD_NANDF_RB0__RAWNAND_READY0 */ + 1360 0xb0b1 /* MX6Q_PAD_NANDF_CS0__RAWNAND_CE0N */ + 1365 0xb0b1 /* MX6Q_PAD_NANDF_CS1__RAWNAND_CE1N */ + 1371 0xb0b1 /* MX6Q_PAD_NANDF_CS2__RAWNAND_CE2N */ + 1378 0xb0b1 /* MX6Q_PAD_NANDF_CS3__RAWNAND_CE3N */ + 1387 0xb0b1 /* MX6Q_PAD_SD4_CMD__RAWNAND_RDN */ + 1393 0xb0b1 /* MX6Q_PAD_SD4_CLK__RAWNAND_WRN */ + 1397 0xb0b1 /* MX6Q_PAD_NANDF_D0__RAWNAND_D0 */ + 1405 0xb0b1 /* MX6Q_PAD_NANDF_D1__RAWNAND_D1 */ + 1413 0xb0b1 /* MX6Q_PAD_NANDF_D2__RAWNAND_D2 */ + 1421 0xb0b1 /* MX6Q_PAD_NANDF_D3__RAWNAND_D3 */ + 1429 0xb0b1 /* MX6Q_PAD_NANDF_D4__RAWNAND_D4 */ + 1437 0xb0b1 /* MX6Q_PAD_NANDF_D5__RAWNAND_D5 */ + 1445 0xb0b1 /* MX6Q_PAD_NANDF_D6__RAWNAND_D6 */ + 1453 0xb0b1 /* MX6Q_PAD_NANDF_D7__RAWNAND_D7 */ + 1463 0x00b1>; /* MX6Q_PAD_SD4_DAT0__RAWNAND_DQS */ + }; + }; + i2c1 { pinctrl_i2c1_1: i2c1grp-1 { fsl,pins = <137 0x4001b8b1 /* MX6Q_PAD_EIM_D21__I2C1_SCL */
Signature · 1 line
1.7.4.4
Shawn Guo
AppliedPATCH v3 2/3 ARM: imx6q: add DT node for gpmi nand
Quoted 9 lines · Huang Shijie
Add the DT node for gpmi nand.
Add the pinmux support for gpmi nand.The gpmi nand may conflicts with other modules, such as MMC. So we do not enable the gpmi nand for mx6q-arm2 board, just add the node for the board.
Acked-by Dong Aisheng <[email protected]>Signed-off-by Huang Shijie <[email protected]>
Applied, thanks.
Signature · 2 lines
Regards, Shawn
PATCH v3 3/3 mtd: gpmi: change the code for clocks
In reply to Huang ShijieThe gpmi nand driver may needs several clocks(MX6Q needs five clocks).
In the old clock framework, all these clocks are chained together, all you need is to manipulate the first clock.
But the kernel uses the common clk framework now, which forces us to get the clocks one by one. When we use them, we have to enable them one by one too.
--- arch/arm/boot/dts/imx6q-arm2.dts | 2 +- drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 43 ++++++++++++++--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 82 ++++++++++++++++++++++++++++---- drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 3 +- 4 files changed, 111 insertions(+), 19 deletions(-)
arch/arm/boot/dts/imx6q-arm2.dts +1 -1
@@ -25,7 +25,7 @@ gpmi-nand at 00112000 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_gpmi_nand_1>; - status = "disabled"; /* gpmi nand conflicts with SD */ + status = "okay"; /* gpmi nand conflicts with SD */ }; aips-bus at 02100000 { /* AIPS2 */
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +35 -8
90 lines not on this page · raw message
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +73 -9
103 lines not on this page · raw message
drivers/mtd/nand/gpmi-nand/gpmi-nand.h +2 -1
@@ -22,6 +22,7 @@#include <linux/dma-mapping.h> #include <linux/fsl/mxs-dma.h> +#define GPMI_CLK_MAX 5/* MX6Q needs five clocks */ struct resources {void *gpmi_regs;void *bch_regs;
@@ -29,7 +30,7 @@ struct resources {unsigned int bch_high_interrupt;unsigned int dma_low_channel;unsigned int dma_high_channel; -struct clk *clock; +struct clk *clock[GPMI_CLK_MAX ]; };/**
Signature · 1 line
1.7.4.4
PATCH v3 3/3 mtd: gpmi: change the code for clocks
? 2012?07?02? 11:38, Huang Shijie ??:
arch/arm/boot/dts/imx6q-arm2.dts line 29
Quoted 3 lines
arch/arm/boot/dts/imx6q-arm2.dts +1
-1- status = "disabled"; /* gpmi nand conflicts with SD */ + status = "okay"; /* gpmi nand conflicts with SD */ };
sorry, this is my mistake.
I will fix it in the next version.
But you can give your comments about other code of this patch.
thanks.
Huang Shijie
PATCH v3 3/3 mtd: gpmi: change the code for clocks
In reply to Huang ShijieQuoted 51 lines · Huang Shijie
The gpmi nand driver may needs several clocks(MX6Q needs five clocks).
In the old clock framework, all these clocks are chained together, all you need is to manipulate the first clock.
But the kernel uses the common clk framework now, which forces us to get the clocks one by one. When we use them, we have to enable them one by one too.
Signed-off-by Huang Shijie <[email protected]>--- arch/arm/boot/dts/imx6q-arm2.dts | 2 +- drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 43 ++++++++++++++--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 82 ++++++++++++++++++++++++++++---- drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 3 +- 4 files changed, 111 insertions(+), 19 deletions(-)arch/arm/boot/dts/imx6q-arm2.dts +1
-1@@ -25,7 +25,7 @@ gpmi-nand at 00112000 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_gpmi_nand_1>; - status = "disabled"; /* gpmi nand conflicts with SD */ + status = "okay"; /* gpmi nand conflicts with SD */ }; aips-bus at 02100000 { /* AIPS2 */drivers/mtd/nand/gpmi-nand/gpmi-lib.c +13
-0@@ -124,12 +124,40 @@ error:return -ETIMEDOUT ; } +static int __gpmi_enable_clk (struct gpmi_nand_data *this,bool v) +{ +struct clk *clk; +int ret; +int i; + +for (i =0 ; i <GPMI_CLK_MAX ; i++) { + clk = this->resources.clock[i]; +if (!clk) +break ; + +if (v) { + ret =clk_prepare_enable (clk);
drivers/mtd/nand/gpmi-nand/gpmi-lib.c error: · line 149
Quoted 10 lines
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +9
-0+if (ret) + goto err_clk; + }else { +clk_disable_unprepare (clk); + } + } +return 0 ; + +err_clk:
Doesn't this design introduce clk_enalbe/disable un-balance problems?
Suppose you successfully enabled 1st and 2nd clocks, and failed at the third clock, this function will return, then the caller function will check the return value and call
__gpmi_enable_clk(this, 0), in this function, it will unconditionally disable all five clocks.
Regards,
Hui.
Quoted 4 lines
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +3
-0+return ret; +} +
PATCH v3 3/3 mtd: gpmi: change the code for clocks
? 2012?07?02? 13:39, Hui Wang ??:
Quoted 66 lines
Quoted 53 lines · Huang Shijie
The gpmi nand driver may needs several clocks(MX6Q needs five clocks).
In the old clock framework, all these clocks are chained together, all you need is to manipulate the first clock.
But the kernel uses the common clk framework now, which forces us to get the clocks one by one. When we use them, we have to enable them one by one too.
Signed-off-by Huang Shijie <[email protected]>---
arch/arm/boot/dts/imx6q-arm2.dts| 2 +-drivers/mtd/nand/gpmi-nand/gpmi-lib.c| 43 ++++++++++++++---drivers/mtd/nand/gpmi-nand/gpmi-nand.c| 82
++++++++++++++++++++++++++++----drivers/mtd/nand/gpmi-nand/gpmi-nand.h| 3 +-4 files changed, 111 insertions(+), 19 deletions(-)arch/arm/boot/dts/imx6q-arm2.dts +1
-1@@ -25,7 +25,7 @@ gpmi-nand at 00112000 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_gpmi_nand_1>; - status = "disabled"; /* gpmi nand conflicts with SD */ + status = "okay"; /* gpmi nand conflicts with SD */ };aips-bus at 02100000 { /* AIPS2 */
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +12
-0@@ -124,12 +124,40 @@ error:return -ETIMEDOUT ; } +static int __gpmi_enable_clk (struct gpmi_nand_data *this,bool v) +{ +struct clk *clk; +int ret; +int i; + +for (i =0 ; i <GPMI_CLK_MAX ; i++) { + clk = this->resources.clock[i]; +if (!clk) +break ; + +if (v) {drivers/mtd/nand/gpmi-nand/gpmi-lib.c error: · line 148
Quoted 10 lines
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +10
-0+ ret =clk_prepare_enable (clk); +if (ret) + goto err_clk; + }else { +clk_disable_unprepare (clk); + } + } +return 0 ; + +err_clk:Doesn't this design introduce clk_enalbe/disable un-balance problems?
Quoted 6 lines
Suppose you successfully enabled 1st and 2nd clocks, and failed at the third clock, this function will return, then the caller function will check the return value and call
__gpmi_enable_clk(this, 0), in this function, it will unconditionally disable all five clocks.
thanks, fix it in next version.
Huang Shijie
Quoted 15 lines
Regards,
Hui.drivers/mtd/nand/gpmi-nand/gpmi-lib.c error: · line 151
Quoted 3 lines
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +3
-0+return ret; +} +_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel