Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-davem' of git://gitorious.org/linux-can/linux-can-next

Marc Kleine-Budde says:

====================
this is a pull-request for net-next/master. It consists of three
patches by Fabio Estevam and me, which convert the flexcan transceiver
switching to DT[1] and a patch by Sachin Kamat, which cleans up the
at91_can driver a bit.

[1] These patches touch arch/arm/mach-imx, so I collected Acked-bys
from Shawn Guo and Sascha Hauer.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+44 -102
+2
Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
··· 16 16 17 17 - clock-frequency : The oscillator frequency driving the flexcan device 18 18 19 + - xceiver-supply: Regulator that powers the CAN transceiver 20 + 19 21 Example: 20 22 21 23 can@1c000 {
+12
arch/arm/boot/dts/imx28-evk.dts
··· 155 155 can0: can@80032000 { 156 156 pinctrl-names = "default"; 157 157 pinctrl-0 = <&can0_pins_a>; 158 + xceiver-supply = <&reg_can_3v3>; 158 159 status = "okay"; 159 160 }; 160 161 161 162 can1: can@80034000 { 162 163 pinctrl-names = "default"; 163 164 pinctrl-0 = <&can1_pins_a>; 165 + xceiver-supply = <&reg_can_3v3>; 164 166 status = "okay"; 165 167 }; 166 168 }; ··· 321 319 gpio = <&gpio3 30 0>; 322 320 enable-active-high; 323 321 }; 322 + 323 + reg_can_3v3: can-3v3 { 324 + compatible = "regulator-fixed"; 325 + regulator-name = "can-3v3"; 326 + regulator-min-microvolt = <3300000>; 327 + regulator-max-microvolt = <3300000>; 328 + gpio = <&gpio2 13 0>; 329 + enable-active-high; 330 + }; 331 + 324 332 }; 325 333 326 334 sound {
+4 -4
arch/arm/mach-imx/devices-imx25.h
··· 13 13 imx_add_fec(&imx25_fec_data, pdata) 14 14 15 15 extern const struct imx_flexcan_data imx25_flexcan_data[]; 16 - #define imx25_add_flexcan(id, pdata) \ 17 - imx_add_flexcan(&imx25_flexcan_data[id], pdata) 18 - #define imx25_add_flexcan0(pdata) imx25_add_flexcan(0, pdata) 19 - #define imx25_add_flexcan1(pdata) imx25_add_flexcan(1, pdata) 16 + #define imx25_add_flexcan(id) \ 17 + imx_add_flexcan(&imx25_flexcan_data[id]) 18 + #define imx25_add_flexcan0() imx25_add_flexcan(0) 19 + #define imx25_add_flexcan1() imx25_add_flexcan(1) 20 20 21 21 extern const struct imx_fsl_usb2_udc_data imx25_fsl_usb2_udc_data; 22 22 #define imx25_add_fsl_usb2_udc(pdata) \
+4 -4
arch/arm/mach-imx/devices-imx35.h
··· 17 17 imx_add_fsl_usb2_udc(&imx35_fsl_usb2_udc_data, pdata) 18 18 19 19 extern const struct imx_flexcan_data imx35_flexcan_data[]; 20 - #define imx35_add_flexcan(id, pdata) \ 21 - imx_add_flexcan(&imx35_flexcan_data[id], pdata) 22 - #define imx35_add_flexcan0(pdata) imx35_add_flexcan(0, pdata) 23 - #define imx35_add_flexcan1(pdata) imx35_add_flexcan(1, pdata) 20 + #define imx35_add_flexcan(id) \ 21 + imx_add_flexcan(&imx35_flexcan_data[id]) 22 + #define imx35_add_flexcan0() imx35_add_flexcan(0) 23 + #define imx35_add_flexcan1() imx35_add_flexcan(1) 24 24 25 25 extern const struct imx_imx2_wdt_data imx35_imx2_wdt_data; 26 26 #define imx35_add_imx2_wdt() \
+1 -3
arch/arm/mach-imx/devices/devices-common.h
··· 50 50 const struct imx_fec_data *data, 51 51 const struct fec_platform_data *pdata); 52 52 53 - #include <linux/can/platform/flexcan.h> 54 53 struct imx_flexcan_data { 55 54 int id; 56 55 resource_size_t iobase; ··· 57 58 resource_size_t irq; 58 59 }; 59 60 struct platform_device *__init imx_add_flexcan( 60 - const struct imx_flexcan_data *data, 61 - const struct flexcan_platform_data *pdata); 61 + const struct imx_flexcan_data *data); 62 62 63 63 #include <linux/fsl_devices.h> 64 64 struct imx_fsl_usb2_udc_data {
+2 -3
arch/arm/mach-imx/devices/platform-flexcan.c
··· 38 38 #endif /* ifdef CONFIG_SOC_IMX35 */ 39 39 40 40 struct platform_device *__init imx_add_flexcan( 41 - const struct imx_flexcan_data *data, 42 - const struct flexcan_platform_data *pdata) 41 + const struct imx_flexcan_data *data) 43 42 { 44 43 struct resource res[] = { 45 44 { ··· 53 54 }; 54 55 55 56 return imx_add_platform_device("flexcan", data->id, 56 - res, ARRAY_SIZE(res), pdata, sizeof(*pdata)); 57 + res, ARRAY_SIZE(res), NULL, 0); 57 58 }
+1 -1
arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c
··· 279 279 imx25_add_imx_fb(&eukrea_mximxsd_fb_pdata); 280 280 imx25_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata); 281 281 282 - imx25_add_flexcan1(NULL); 282 + imx25_add_flexcan1(); 283 283 imx25_add_sdhci_esdhc_imx(0, &sd1_pdata); 284 284 285 285 gpio_request(GPIO_LED1, "LED1");
+1 -1
arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c
··· 287 287 288 288 imx35_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata); 289 289 290 - imx35_add_flexcan1(NULL); 290 + imx35_add_flexcan1(); 291 291 imx35_add_sdhci_esdhc_imx(0, &sd1_pdata); 292 292 293 293 gpio_request(GPIO_LED1, "LED1");
+1 -1
arch/arm/mach-imx/mach-mx25_3ds.c
··· 249 249 imx25_add_imx_i2c0(&mx25_3ds_i2c0_data); 250 250 251 251 gpio_request_one(MX25PDK_CAN_PWDN, GPIOF_OUT_INIT_LOW, "can-pwdn"); 252 - imx25_add_flexcan0(NULL); 252 + imx25_add_flexcan0(); 253 253 } 254 254 255 255 static void __init mx25pdk_timer_init(void)
+1 -1
arch/arm/mach-imx/mach-pcm043.c
··· 385 385 if (!otg_mode_host) 386 386 imx35_add_fsl_usb2_udc(&otg_device_pdata); 387 387 388 - imx35_add_flexcan1(NULL); 388 + imx35_add_flexcan1(); 389 389 imx35_add_sdhci_esdhc_imx(0, &sd1_pdata); 390 390 } 391 391
+1 -49
arch/arm/mach-mxs/mach-mxs.c
··· 14 14 #include <linux/clk/mxs.h> 15 15 #include <linux/clkdev.h> 16 16 #include <linux/clocksource.h> 17 - #include <linux/can/platform/flexcan.h> 18 17 #include <linux/delay.h> 19 18 #include <linux/err.h> 20 19 #include <linux/gpio.h> ··· 58 59 { 59 60 __raw_writel(mask, reg + MXS_TOG_ADDR); 60 61 } 61 - 62 - /* 63 - * MX28EVK_FLEXCAN_SWITCH is shared between both flexcan controllers 64 - */ 65 - #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13) 66 - 67 - static int flexcan0_en, flexcan1_en; 68 - 69 - static void mx28evk_flexcan_switch(void) 70 - { 71 - if (flexcan0_en || flexcan1_en) 72 - gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 1); 73 - else 74 - gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 0); 75 - } 76 - 77 - static void mx28evk_flexcan0_switch(int enable) 78 - { 79 - flexcan0_en = enable; 80 - mx28evk_flexcan_switch(); 81 - } 82 - 83 - static void mx28evk_flexcan1_switch(int enable) 84 - { 85 - flexcan1_en = enable; 86 - mx28evk_flexcan_switch(); 87 - } 88 - 89 - static struct flexcan_platform_data flexcan_pdata[2]; 90 - 91 - static struct of_dev_auxdata mxs_auxdata_lookup[] __initdata = { 92 - OF_DEV_AUXDATA("fsl,imx28-flexcan", 0x80032000, NULL, &flexcan_pdata[0]), 93 - OF_DEV_AUXDATA("fsl,imx28-flexcan", 0x80034000, NULL, &flexcan_pdata[1]), 94 - { /* sentinel */ } 95 - }; 96 62 97 63 #define OCOTP_WORD_OFFSET 0x20 98 64 #define OCOTP_WORD_COUNT 0x20 ··· 218 254 mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0); 219 255 } 220 256 221 - static void __init imx28_evk_post_init(void) 222 - { 223 - if (!gpio_request_one(MX28EVK_FLEXCAN_SWITCH, GPIOF_DIR_OUT, 224 - "flexcan-switch")) { 225 - flexcan_pdata[0].transceiver_switch = mx28evk_flexcan0_switch; 226 - flexcan_pdata[1].transceiver_switch = mx28evk_flexcan1_switch; 227 - } 228 - } 229 - 230 257 static int apx4devkit_phy_fixup(struct phy_device *phy) 231 258 { 232 259 phy->dev_flags |= MICREL_PHY_50MHZ_CLK; ··· 329 374 cfa10049_init(); 330 375 331 376 of_platform_populate(NULL, of_default_bus_match_table, 332 - mxs_auxdata_lookup, NULL); 377 + NULL, NULL); 333 378 334 379 if (of_machine_is_compatible("karo,tx28")) 335 380 tx28_post_init(); 336 - 337 - if (of_machine_is_compatible("fsl,imx28-evk")) 338 - imx28_evk_post_init(); 339 381 } 340 382 341 383 #define MX23_CLKCTRL_RESET_OFFSET 0x120
+1 -3
drivers/net/can/at91_can.c
··· 1264 1264 } 1265 1265 }; 1266 1266 MODULE_DEVICE_TABLE(of, at91_can_dt_ids); 1267 - #else 1268 - #define at91_can_dt_ids NULL 1269 1267 #endif 1270 1268 1271 1269 static const struct at91_devtype_data *at91_can_get_driver_data(struct platform_device *pdev) ··· 1422 1424 .driver = { 1423 1425 .name = KBUILD_MODNAME, 1424 1426 .owner = THIS_MODULE, 1425 - .of_match_table = at91_can_dt_ids, 1427 + .of_match_table = of_match_ptr(at91_can_dt_ids), 1426 1428 }, 1427 1429 .id_table = at91_can_id_table, 1428 1430 };
+13 -12
drivers/net/can/flexcan.c
··· 24 24 #include <linux/can/dev.h> 25 25 #include <linux/can/error.h> 26 26 #include <linux/can/led.h> 27 - #include <linux/can/platform/flexcan.h> 28 27 #include <linux/clk.h> 29 28 #include <linux/delay.h> 30 29 #include <linux/if_arp.h> ··· 36 37 #include <linux/of.h> 37 38 #include <linux/of_device.h> 38 39 #include <linux/platform_device.h> 40 + #include <linux/regulator/consumer.h> 39 41 40 42 #define DRV_NAME "flexcan" 41 43 ··· 211 211 struct clk *clk_per; 212 212 struct flexcan_platform_data *pdata; 213 213 const struct flexcan_devtype_data *devtype_data; 214 + struct regulator *reg_xceiver; 214 215 }; 215 216 216 217 static struct flexcan_devtype_data fsl_p1010_devtype_data = { ··· 258 257 writel(val, addr); 259 258 } 260 259 #endif 261 - 262 - /* 263 - * Swtich transceiver on or off 264 - */ 265 - static void flexcan_transceiver_switch(const struct flexcan_priv *priv, int on) 266 - { 267 - if (priv->pdata && priv->pdata->transceiver_switch) 268 - priv->pdata->transceiver_switch(on); 269 - } 270 260 271 261 static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv, 272 262 u32 reg_esr) ··· 791 799 if (priv->devtype_data->features & FLEXCAN_HAS_V10_FEATURES) 792 800 flexcan_write(0x0, &regs->rxfgmask); 793 801 794 - flexcan_transceiver_switch(priv, 1); 802 + if (priv->reg_xceiver) { 803 + err = regulator_enable(priv->reg_xceiver); 804 + if (err) 805 + goto out; 806 + } 795 807 796 808 /* synchronize with the can bus */ 797 809 reg_mcr = flexcan_read(&regs->mcr); ··· 838 842 reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT; 839 843 flexcan_write(reg, &regs->mcr); 840 844 841 - flexcan_transceiver_switch(priv, 0); 845 + if (priv->reg_xceiver) 846 + regulator_disable(priv->reg_xceiver); 842 847 priv->can.state = CAN_STATE_STOPPED; 843 848 844 849 return; ··· 1080 1083 priv->clk_per = clk_per; 1081 1084 priv->pdata = pdev->dev.platform_data; 1082 1085 priv->devtype_data = devtype_data; 1086 + 1087 + priv->reg_xceiver = devm_regulator_get(&pdev->dev, "xceiver"); 1088 + if (IS_ERR(priv->reg_xceiver)) 1089 + priv->reg_xceiver = NULL; 1083 1090 1084 1091 netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT); 1085 1092
-20
include/linux/can/platform/flexcan.h
··· 1 - /* 2 - * Copyright (C) 2010 Marc Kleine-Budde <kernel@pengutronix.de> 3 - * 4 - * This file is released under the GPLv2 5 - * 6 - */ 7 - 8 - #ifndef __CAN_PLATFORM_FLEXCAN_H 9 - #define __CAN_PLATFORM_FLEXCAN_H 10 - 11 - /** 12 - * struct flexcan_platform_data - flex CAN controller platform data 13 - * @transceiver_enable: - called to power on/off the transceiver 14 - * 15 - */ 16 - struct flexcan_platform_data { 17 - void (*transceiver_switch)(int enable); 18 - }; 19 - 20 - #endif /* __CAN_PLATFORM_FLEXCAN_H */