i2c-mpc: add support for the Freescale MPC512x and other fixes
Subsystems (3)
v6 cover i2c-mpc: add support for the Freescale MPC512x and other fixes
From: Wolfgang Grandegger <[email protected]>
This patch series adds support for the MPC512x from Freescale to the i2c-mpc driver. At that occasion, issues with __devinit[data] have been fixed and the doc of the FSL I2C dts bindings updated. It has been tested on a MPC5121ADS, TQM5200 and TQM8560 board
Changes since v1:
- use macro MPC_I2C_CLOCK_PRESERVE/SAFE for the special clock settings.
- document the special DTS node "fsl,mpc5121-i2c-ctrl".
- update and correct the Kconfig help.
- some other minor fixes as suggested by Wolfram.
Changes since v2:
- use __init[data] instead of __devinit[data] for this driver.
Changes since v3:
- switch back to __devinit[data] as pointed out by Ben.
Changes since v4:
- check MPC_I2C_CLOCK_SAFE instead of "!clock" as suggested by Wolfram.
- update MODULE_DESCRIPTION().
Changes since v5 (suggested by Grant Likely):
- various correctings for labling initialization functions and data (this is tricky because section mismatches are not always obvious).
- add a separate patch for renaming the setclock into setup functions.
- correct the doc of the I2C bindings, e.g. don't mention the legacy clock setting and remove obsolte parts.
Wolfgang
Wolfgang Grandegger (4):
i2c-mpc: use __devinit[data] for initialization functions and data
i2c-mpc: rename "setclock" initialization functions to "setup"
i2c-mpc: add support for the MPC512x processors from Freescale
powerpc: doc/dts-bindings: update doc of FSL I2C bindings
Documentation/powerpc/dts-bindings/fsl/i2c.txt | 30 +++- drivers/i2c/busses/Kconfig | 7 +- drivers/i2c/busses/i2c-mpc.c | 194 +++++++++++++++--------- 3 files changed, 146 insertions(+), 85 deletions(-)
PATCH v6 1/4 i2c-mpc: use __devinit[data] for initialization functions and data
In reply to a message not in the archiveFrom: Wolfgang Grandegger <[email protected]>
"__devinit[data]" has not yet been used for all initialization functions and data. To avoid truncating lines, the struct "mpc_i2c_match_data" has been renamed to "mpc_i2c_data", which is even the better name.
--- drivers/i2c/busses/i2c-mpc.c | 99 +++++++++++++++++++---------------------- 1 files changed, 46 insertions(+), 53 deletions(-)
drivers/i2c/busses/i2c-mpc.c +46 -53
@@ -66,7 +66,7 @@ struct mpc_i2c_divider {u16 fdr;/* including dfsrr */ }; -struct mpc_i2c_match_data { +struct mpc_i2c_data {void (*setclock)(struct device_node *node,struct mpc_i2c *i2c,u32 clock,u32 prescaler);
@@ -165,7 +165,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing) }#ifdef CONFIG_PPC_MPC52xx -static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = { +static struct mpc_i2c_divider mpc_i2c_dividers_52xx[]__devinitdata = { {20 ,0x20 }, {22 ,0x21 }, {24 ,0x22 }, {26 ,0x23 }, {28 ,0x24 }, {30 ,0x01 }, {32 ,0x25 }, {34 ,0x02 }, {36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28},
@@ -186,7 +186,8 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = { {10240, 0x9d}, {12288, 0x9e}, {15360, 0x9f} }; -int mpc_i2c_get_fdr_52xx (struct device_node *node,u32 clock,int prescaler) +static int __devinit mpc_i2c_get_fdr_52xx (struct device_node *node,u32 clock, +int prescaler) {const struct mpc_i2c_divider *div =NULL ;unsigned int pvr =mfspr (SPRN_PVR );
@@ -215,9 +216,9 @@ int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)return div ? (int )div->fdr : -EINVAL ; } -static void mpc_i2c_setclock_52xx (struct device_node *node, -struct mpc_i2c *i2c, -u32 clock,u32 prescaler) +static void __devinit mpc_i2c_setclock_52xx (struct device_node *node, +struct mpc_i2c *i2c, +u32 clock,u32 prescaler) {int ret, fdr;
@@ -230,15 +231,15 @@ static void mpc_i2c_setclock_52xx(struct device_node *node,dev_info (i2c->dev,"clock %d Hz (fdr=%d)\n" , clock, fdr); }#else /* !CONFIG_PPC_MPC52xx */ -static void mpc_i2c_setclock_52xx (struct device_node *node, -struct mpc_i2c *i2c, -u32 clock,u32 prescaler) +static void __devinit mpc_i2c_setclock_52xx (struct device_node *node, +struct mpc_i2c *i2c, +u32 clock,u32 prescaler) { }#endif /* CONFIG_PPC_MPC52xx*/ #ifdef CONFIG_FSL_SOC -static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = { +static struct mpc_i2c_divider mpc_i2c_dividers_8xxx[]__devinitdata = { {160 ,0x0120 }, {192 ,0x0121 }, {224 ,0x0122 }, {256 ,0x0123 }, {288 ,0x0100 }, {320 ,0x0101 }, {352 ,0x0601 }, {384 ,0x0102 }, {416, 0x0602}, {448, 0x0126}, {480, 0x0103}, {512, 0x0127},
@@ -258,7 +259,7 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = { {49152, 0x011e}, {61440, 0x011f} }; -u32 mpc_i2c_get_sec_cfg_8xxx (void ) +static u32 __devinit mpc_i2c_get_sec_cfg_8xxx (void ) {struct device_node *node =NULL ;u32 __iomem *reg;
@@ -287,7 +288,8 @@ u32 mpc_i2c_get_sec_cfg_8xxx(void)return val; } -int mpc_i2c_get_fdr_8xxx (struct device_node *node,u32 clock,u32 prescaler) +static int __devinit mpc_i2c_get_fdr_8xxx (struct device_node *node,u32 clock, +u32 prescaler) {const struct mpc_i2c_divider *div =NULL ;u32 divider;
@@ -320,9 +322,9 @@ int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 prescaler)return div ? (int )div->fdr : -EINVAL ; } -static void mpc_i2c_setclock_8xxx (struct device_node *node, -struct mpc_i2c *i2c, -u32 clock,u32 prescaler) +static void __devinit mpc_i2c_setclock_8xxx (struct device_node *node, +struct mpc_i2c *i2c, +u32 clock,u32 prescaler) {int ret, fdr;
@@ -338,9 +340,9 @@ static void mpc_i2c_setclock_8xxx(struct device_node *node, }#else /* !CONFIG_FSL_SOC */ -static void mpc_i2c_setclock_8xxx (struct device_node *node, -struct mpc_i2c *i2c, -u32 clock,u32 prescaler) +static void __devinit mpc_i2c_setclock_8xxx (struct device_node *node, +struct mpc_i2c *i2c, +u32 clock,u32 prescaler) { }#endif /* CONFIG_FSL_SOC */
@@ -529,8 +531,8 @@ static int __devinit fsl_i2c_probe(struct of_device *op, clock = *prop;if (match->data) { -struct mpc_i2c_match_data *data = - (struct mpc_i2c_match_data *)match->data; +struct mpc_i2c_data *data = + (struct mpc_i2c_data *)match->data; data->setclock (op->node, i2c, clock, data->prescaler); }else {/* Backwards compatibility */
@@ -582,44 +584,35 @@ static int __devexit fsl_i2c_remove(struct of_device *op)return 0 ; }; +static struct mpc_i2c_data mpc_i2c_data_52xx__devinitdata = { + .setup = mpc_i2c_setup_52xx, +}; + +static struct mpc_i2c_data mpc_i2c_data_8313__devinitdata = { + .setup = mpc_i2c_setup_8xxx, +}; + +static struct mpc_i2c_data mpc_i2c_data_8543__devinitdata = { + .setup = mpc_i2c_setup_8xxx, + .prescaler =2 , +}; + +static struct mpc_i2c_data mpc_i2c_data_8544__devinitdata = { + .setup = mpc_i2c_setup_8xxx, + .prescaler =3 , +}; +static const struct of_device_id mpc_i2c_of_match[] = { - {.compatible ="mpc5200-i2c" , - .data = &(struct mpc_i2c_match_data ) { - .setclock = mpc_i2c_setclock_52xx, - }, - }, - {.compatible ="fsl,mpc5200b-i2c" , - .data = &(struct mpc_i2c_match_data ) { - .setclock = mpc_i2c_setclock_52xx, - }, - }, - {.compatible ="fsl,mpc5200-i2c" , - .data = &(struct mpc_i2c_match_data ) { - .setclock = mpc_i2c_setclock_52xx, - }, - }, - {.compatible ="fsl,mpc8313-i2c" , - .data = &(struct mpc_i2c_match_data ) { - .setclock = mpc_i2c_setclock_8xxx, - }, - }, - {.compatible ="fsl,mpc8543-i2c" , - .data = &(struct mpc_i2c_match_data ) { - .setclock = mpc_i2c_setclock_8xxx, - .prescaler =2 , - }, - }, - {.compatible ="fsl,mpc8544-i2c" , - .data = &(struct mpc_i2c_match_data ) { - .setclock = mpc_i2c_setclock_8xxx, - .prescaler =3 , - }, + {.compatible ="mpc5200-i2c" , .data = &mpc_i2c_data_52xx, }, + {.compatible ="fsl,mpc5200b-i2c" , .data = &mpc_i2c_data_52xx, }, + {.compatible ="fsl,mpc5200-i2c" , .data = &mpc_i2c_data_52xx, }, + {.compatible ="fsl,mpc8313-i2c" , .data = &mpc_i2c_data_8313, }, + {.compatible ="fsl,mpc8543-i2c" , .data = &mpc_i2c_data_8543, }, + {.compatible ="fsl,mpc8544-i2c" , .data = &mpc_i2c_data_8544, },/* Backward compatibility */ - }, {.compatible ="fsl-i2c" , }, {}, }; -MODULE_DEVICE_TABLE (of, mpc_i2c_of_match);
Signature · 1 line
1.6.2.5
PATCH v6 2/4 i2c-mpc: rename "setclock" initialization functions to "setup"
In reply to a message not in the archiveFrom: Wolfgang Grandegger <[email protected]>
To prepare support for the MPC512x processors from Freescale the "setclock" initialization functions have been renamed to "setup" because I2C interrupts must be enabled for the MPC512x by this function as well.
--- drivers/i2c/busses/i2c-mpc.c | 34 ++++++++++++++++------------------ 1 files changed, 16 insertions(+), 18 deletions(-)
drivers/i2c/busses/i2c-mpc.c +16 -18
@@ -67,9 +67,8 @@ struct mpc_i2c_divider { };struct mpc_i2c_data { -void (*setclock)(struct device_node *node, -struct mpc_i2c *i2c, -u32 clock,u32 prescaler); +void (*setup)(struct device_node *node,struct mpc_i2c *i2c, +u32 clock,u32 prescaler);u32 prescaler; };
@@ -216,9 +215,9 @@ static int __devinit mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock,return div ? (int )div->fdr : -EINVAL ; } -static void __devinit mpc_i2c_setclock_52xx (struct device_node *node, -struct mpc_i2c *i2c, -u32 clock,u32 prescaler) +static void __devinit mpc_i2c_setup_52xx (struct device_node *node, +struct mpc_i2c *i2c, +u32 clock,u32 prescaler) {int ret, fdr;
@@ -231,9 +230,9 @@ static void __devinit mpc_i2c_setclock_52xx(struct device_node *node, dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr); }#else /* !CONFIG_PPC_MPC52xx */ -static void __devinit mpc_i2c_setclock_52xx (struct device_node *node, -struct mpc_i2c *i2c, -u32 clock,u32 prescaler) +static void __devinit mpc_i2c_setup_52xx (struct device_node *node, +struct mpc_i2c *i2c, +u32 clock,u32 prescaler) { }#endif /* CONFIG_PPC_MPC52xx*/
@@ -322,9 +321,9 @@ static int __devinit mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock,return div ? (int )div->fdr : -EINVAL ; } -static void __devinit mpc_i2c_setclock_8xxx (struct device_node *node, -struct mpc_i2c *i2c, -u32 clock,u32 prescaler) +static void __devinit mpc_i2c_setup_8xxx (struct device_node *node, +struct mpc_i2c *i2c, +u32 clock,u32 prescaler) {int ret, fdr;
@@ -340,9 +339,9 @@ static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node, }#else /* !CONFIG_FSL_SOC */ -static void __devinit mpc_i2c_setclock_8xxx (struct device_node *node, -struct mpc_i2c *i2c, -u32 clock,u32 prescaler) +static void __devinit mpc_i2c_setup_8xxx (struct device_node *node, +struct mpc_i2c *i2c, +u32 clock,u32 prescaler) { }#endif /* CONFIG_FSL_SOC */
@@ -533,12 +532,11 @@ static int __devinit fsl_i2c_probe(struct of_device *op,if (match->data) {struct mpc_i2c_data *data = (struct mpc_i2c_data *)match->data; - data->setclock (op->node, i2c, clock, data->prescaler); + data->setup (op->node, i2c, clock, data->prescaler); }else {/* Backwards compatibility */ if (of_get_property (op->node,"dfsrr" ,NULL )) -mpc_i2c_setclock_8xxx (op->node, i2c, - clock,0 ); +mpc_i2c_setup_8xxx (op->node, i2c, clock,0 ); } }
Signature · 1 line
1.6.2.5
PATCH v6 3/4 i2c-mpc: add support for the MPC512x processors from Freescale
In reply to a message not in the archiveFrom: Wolfgang Grandegger <[email protected]>
As I2C interrupts must be enabled for the MPC512x by the setup function as well, "fsl,preserve-clocking" is handled in a slighly different way. Also, the old settings are now reported calling dev_dbg(). For the MPC512x the clock setup function of the MPC52xx can be re-used. Furthermore, the Kconfig help has been updated and corrected.
--- drivers/i2c/busses/Kconfig | 7 +-- drivers/i2c/busses/i2c-mpc.c | 93 +++++++++++++++++++++++++++++++++-------- 2 files changed, 78 insertions(+), 22 deletions(-)
drivers/i2c/busses/Kconfig +3 -4
@@ -418,13 +418,12 @@ config I2C_IXP2000 instead. config I2C_MPC - tristate "MPC107/824x/85xx/52xx/86xx" + tristate "MPC107/824x/85xx/512x/52xx/83xx/86xx" depends on PPC32 help If you say yes to this option, support will be included for the - built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and - MPC85xx/MPC8641 family processors. The driver may also work on 52xx - family processors, though interrupts are known not to work. + built-in I2C interface on the MPC107, Tsi107, MPC512x, MPC52xx, + MPC8240, MPC8245, MPC83xx, MPC85xx and MPC8641 family processors. This driver can also be built as a module. If so, the module will be called i2c-mpc.
drivers/i2c/busses/i2c-mpc.c +75 -18
178 lines not on this page · raw message
Signature · 1 line
1.6.2.5
PATCH v6 4/4 powerpc: doc/dts-bindings: update doc of FSL I2C bindings
In reply to a message not in the archiveFrom: Wolfgang Grandegger <[email protected]>
This patch adds the MPC5121 to the list of supported devices, enhances the doc of the "clock-frequency" property and removes the obsolete "cell-index", "device_type" and "fsl-i2c" property. Furthermore an example for the MPC5121 has been added.
--- Documentation/powerpc/dts-bindings/fsl/i2c.txt | 30 +++++++++++++++++------ 1 files changed, 22 insertions(+), 8 deletions(-)
Documentation/powerpc/dts-bindings/fsl/i2c.txt +22 -8
@@ -2,15 +2,14 @@ Required properties : - - device_type : Should be "i2c" - reg : Offset and length of the register set for the device + - compatible : should be "fsl,CHIP-i2c" where CHIP is the name of a + compatible processor, e.g. mpc8313, mpc8543, mpc8544, mpc5121, + mpc5200 or mpc5200b. For the mpc5121, an additional node + "fsl,mpc5121-i2c-ctrl" is required as shown in the example below. Recommended properties : - - compatible : compatibility list with 2 entries, the first should - be "fsl,CHIP-i2c" where CHIP is the name of a compatible processor, - e.g. mpc8313, mpc8543, mpc8544, mpc5200 or mpc5200b. The second one - should be "fsl-i2c". - interrupts : <a b> where a is the interrupt number and b is a field that represents an encoding of the sense and level information for the interrupt. This should be encoded based on
@@ -24,25 +23,40 @@ Recommended properties : Examples : + /* MPC5121 based board */ + i2c@1740 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "fsl,mpc5121-i2c", "fsl-i2c"; + reg = <0x1740 0x20>; + interrupts = <11 0x8>; + interrupt-parent = <&ipic>; + clock-frequency = <100000>; + }; + + i2ccontrol@1760 { + compatible = "fsl,mpc5121-i2c-ctrl"; + reg = <0x1760 0x8>; + }; + + /* MPC5200B based board */ i2c@3d00 { #address-cells = <1>; #size-cells = <0>; compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c"; - cell-index = <0>; reg = <0x3d00 0x40>; interrupts = <2 15 0>; interrupt-parent = <&mpc5200_pic>; fsl,preserve-clocking; }; + /* MPC8544 base board */ i2c@3100 { #address-cells = <1>; #size-cells = <0>; - cell-index = <1>; compatible = "fsl,mpc8544-i2c", "fsl-i2c"; reg = <0x3100 0x100>; interrupts = <43 2>; interrupt-parent = <&mpic>; clock-frequency = <400000>; }; -
Signature · 1 line
1.6.2.5
Wolfram Sang
Acked-byRe: [PATCH v6 2/4] i2c-mpc: rename "setclock" initialization functions to "setup"
In reply to a message not in the archiveQuoted 8 lines · Wolfgang Grandegger
From: Wolfgang Grandegger <[email protected]>
To prepare support for the MPC512x processors from Freescale the "setclock" initialization functions have been renamed to "setup" because I2C interrupts must be enabled for the MPC512x by this function as well.
Signed-off-by Wolfgang Grandegger <[email protected]>
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |