aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2012-02-21 08:31:45 -0500
committerLinus Walleij <linus.walleij@linaro.org>2012-02-22 11:59:33 -0500
commit128a06d4bb997d90158e668173a6944d376c84cb (patch)
treecbfe9ed922f93fa4132d8d6db6e3a22aeb8637fa
parent4ecce45dd663f6945bed7e2e06c05b5d90f3a2a1 (diff)
pinctrl: spawn U300 pinctrl from the COH901 GPIO
This solves the riddle on how the U300 pin controller shall be able to reference the struct gpio_chip even though these are two separate drivers: spawn the pinctrl child from the GPIO driver and pass in the struct gpio_chip as platform data. In the process we rename the U300 "pinmux-u300" to "pinctrl-u300" so as not to confuse. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--arch/arm/mach-u300/core.c30
-rw-r--r--arch/arm/mach-u300/include/mach/gpio-u300.h2
-rw-r--r--drivers/pinctrl/pinctrl-coh901.c10
-rw-r--r--drivers/pinctrl/pinctrl-u300.c20
4 files changed, 38 insertions, 24 deletions
diff --git a/arch/arm/mach-u300/core.c b/arch/arm/mach-u300/core.c
index bb1034f8c2f5..030b2c0d322d 100644
--- a/arch/arm/mach-u300/core.c
+++ b/arch/arm/mach-u300/core.c
@@ -1477,7 +1477,7 @@ static struct coh901318_platform coh901318_platform = {
1477 .max_channels = U300_DMA_CHANNELS, 1477 .max_channels = U300_DMA_CHANNELS,
1478}; 1478};
1479 1479
1480static struct resource pinmux_resources[] = { 1480static struct resource pinctrl_resources[] = {
1481 { 1481 {
1482 .start = U300_SYSCON_BASE, 1482 .start = U300_SYSCON_BASE,
1483 .end = U300_SYSCON_BASE + SZ_4K - 1, 1483 .end = U300_SYSCON_BASE + SZ_4K - 1,
@@ -1506,6 +1506,13 @@ static struct platform_device i2c1_device = {
1506 .resource = i2c1_resources, 1506 .resource = i2c1_resources,
1507}; 1507};
1508 1508
1509static struct platform_device pinctrl_device = {
1510 .name = "pinctrl-u300",
1511 .id = -1,
1512 .num_resources = ARRAY_SIZE(pinctrl_resources),
1513 .resource = pinctrl_resources,
1514};
1515
1509/* 1516/*
1510 * The different variants have a few different versions of the 1517 * The different variants have a few different versions of the
1511 * GPIO block, with different number of ports. 1518 * GPIO block, with different number of ports.
@@ -1525,6 +1532,7 @@ static struct u300_gpio_platform u300_gpio_plat = {
1525#endif 1532#endif
1526 .gpio_base = 0, 1533 .gpio_base = 0,
1527 .gpio_irq_base = IRQ_U300_GPIO_BASE, 1534 .gpio_irq_base = IRQ_U300_GPIO_BASE,
1535 .pinctrl_device = &pinctrl_device,
1528}; 1536};
1529 1537
1530static struct platform_device gpio_device = { 1538static struct platform_device gpio_device = {
@@ -1597,23 +1605,16 @@ static struct platform_device dma_device = {
1597 }, 1605 },
1598}; 1606};
1599 1607
1600static struct platform_device pinmux_device = {
1601 .name = "pinmux-u300",
1602 .id = -1,
1603 .num_resources = ARRAY_SIZE(pinmux_resources),
1604 .resource = pinmux_resources,
1605};
1606
1607/* Pinmux settings */ 1608/* Pinmux settings */
1608static struct pinctrl_map __initdata u300_pinmux_map[] = { 1609static struct pinctrl_map __initdata u300_pinmux_map[] = {
1609 /* anonymous maps for chip power and EMIFs */ 1610 /* anonymous maps for chip power and EMIFs */
1610 PIN_MAP_SYS_HOG("POWER", "pinmux-u300", "power"), 1611 PIN_MAP_SYS_HOG("POWER", "pinctrl-u300", "power"),
1611 PIN_MAP_SYS_HOG("EMIF0", "pinmux-u300", "emif0"), 1612 PIN_MAP_SYS_HOG("EMIF0", "pinctrl-u300", "emif0"),
1612 PIN_MAP_SYS_HOG("EMIF1", "pinmux-u300", "emif1"), 1613 PIN_MAP_SYS_HOG("EMIF1", "pinctrl-u300", "emif1"),
1613 /* per-device maps for MMC/SD, SPI and UART */ 1614 /* per-device maps for MMC/SD, SPI and UART */
1614 PIN_MAP("MMCSD", "pinmux-u300", "mmc0", "mmci"), 1615 PIN_MAP("MMCSD", "pinctrl-u300", "mmc0", "mmci"),
1615 PIN_MAP("SPI", "pinmux-u300", "spi0", "pl022"), 1616 PIN_MAP("SPI", "pinctrl-u300", "spi0", "pl022"),
1616 PIN_MAP("UART0", "pinmux-u300", "uart0", "uart0"), 1617 PIN_MAP("UART0", "pinctrl-u300", "uart0", "uart0"),
1617}; 1618};
1618 1619
1619struct u300_mux_hog { 1620struct u300_mux_hog {
@@ -1676,7 +1677,6 @@ static struct platform_device *platform_devs[] __initdata = {
1676 &gpio_device, 1677 &gpio_device,
1677 &nand_device, 1678 &nand_device,
1678 &wdog_device, 1679 &wdog_device,
1679 &pinmux_device,
1680}; 1680};
1681 1681
1682/* 1682/*
diff --git a/arch/arm/mach-u300/include/mach/gpio-u300.h b/arch/arm/mach-u300/include/mach/gpio-u300.h
index bf4c7935aecd..e81400c1753a 100644
--- a/arch/arm/mach-u300/include/mach/gpio-u300.h
+++ b/arch/arm/mach-u300/include/mach/gpio-u300.h
@@ -24,12 +24,14 @@ enum u300_gpio_variant {
24 * @ports: number of GPIO block ports 24 * @ports: number of GPIO block ports
25 * @gpio_base: first GPIO number for this block (use a free range) 25 * @gpio_base: first GPIO number for this block (use a free range)
26 * @gpio_irq_base: first GPIO IRQ number for this block (use a free range) 26 * @gpio_irq_base: first GPIO IRQ number for this block (use a free range)
27 * @pinctrl_device: pin control device to spawn as child
27 */ 28 */
28struct u300_gpio_platform { 29struct u300_gpio_platform {
29 enum u300_gpio_variant variant; 30 enum u300_gpio_variant variant;
30 u8 ports; 31 u8 ports;
31 int gpio_base; 32 int gpio_base;
32 int gpio_irq_base; 33 int gpio_irq_base;
34 struct platform_device *pinctrl_device;
33}; 35};
34 36
35#endif /* __MACH_U300_GPIO_U300_H */ 37#endif /* __MACH_U300_GPIO_U300_H */
diff --git a/drivers/pinctrl/pinctrl-coh901.c b/drivers/pinctrl/pinctrl-coh901.c
index eba232a46a82..b90c01144fea 100644
--- a/drivers/pinctrl/pinctrl-coh901.c
+++ b/drivers/pinctrl/pinctrl-coh901.c
@@ -705,7 +705,6 @@ static inline void u300_gpio_free_ports(struct u300_gpio *gpio)
705 list_for_each_safe(p, n, &gpio->port_list) { 705 list_for_each_safe(p, n, &gpio->port_list) {
706 port = list_entry(p, struct u300_gpio_port, node); 706 port = list_entry(p, struct u300_gpio_port, node);
707 list_del(&port->node); 707 list_del(&port->node);
708 free_irq(port->irq, port);
709 kfree(port); 708 kfree(port);
710 } 709 }
711} 710}
@@ -861,10 +860,18 @@ static int __init u300_gpio_probe(struct platform_device *pdev)
861 goto err_no_chip; 860 goto err_no_chip;
862 } 861 }
863 862
863 /* Spawn pin controller device as child of the GPIO, pass gpio chip */
864 plat->pinctrl_device->dev.platform_data = &gpio->chip;
865 err = platform_device_register(plat->pinctrl_device);
866 if (err)
867 goto err_no_pinctrl;
868
864 platform_set_drvdata(pdev, gpio); 869 platform_set_drvdata(pdev, gpio);
865 870
866 return 0; 871 return 0;
867 872
873err_no_pinctrl:
874 err = gpiochip_remove(&gpio->chip);
868err_no_chip: 875err_no_chip:
869err_no_port: 876err_no_port:
870 u300_gpio_free_ports(gpio); 877 u300_gpio_free_ports(gpio);
@@ -919,7 +926,6 @@ static struct platform_driver u300_gpio_driver = {
919 .remove = __exit_p(u300_gpio_remove), 926 .remove = __exit_p(u300_gpio_remove),
920}; 927};
921 928
922
923static int __init u300_gpio_init(void) 929static int __init u300_gpio_init(void)
924{ 930{
925 return platform_driver_probe(&u300_gpio_driver, u300_gpio_probe); 931 return platform_driver_probe(&u300_gpio_driver, u300_gpio_probe);
diff --git a/drivers/pinctrl/pinctrl-u300.c b/drivers/pinctrl/pinctrl-u300.c
index c8d02f1c2b5e..fc4a281caba5 100644
--- a/drivers/pinctrl/pinctrl-u300.c
+++ b/drivers/pinctrl/pinctrl-u300.c
@@ -162,7 +162,7 @@
162#define U300_SYSCON_PMC4R_APP_MISC_16_APP_UART1_CTS 0x0100 162#define U300_SYSCON_PMC4R_APP_MISC_16_APP_UART1_CTS 0x0100
163#define U300_SYSCON_PMC4R_APP_MISC_16_EMIF_1_STATIC_CS5_N 0x0200 163#define U300_SYSCON_PMC4R_APP_MISC_16_EMIF_1_STATIC_CS5_N 0x0200
164 164
165#define DRIVER_NAME "pinmux-u300" 165#define DRIVER_NAME "pinctrl-u300"
166 166
167/* 167/*
168 * The DB3350 has 467 pads, I have enumerated the pads clockwise around the 168 * The DB3350 has 467 pads, I have enumerated the pads clockwise around the
@@ -1053,13 +1053,16 @@ static struct pinctrl_desc u300_pmx_desc = {
1053 .owner = THIS_MODULE, 1053 .owner = THIS_MODULE,
1054}; 1054};
1055 1055
1056static int __init u300_pmx_probe(struct platform_device *pdev) 1056static int __devinit u300_pmx_probe(struct platform_device *pdev)
1057{ 1057{
1058 struct u300_pmx *upmx; 1058 struct u300_pmx *upmx;
1059 struct resource *res; 1059 struct resource *res;
1060 struct gpio_chip *gpio_chip = dev_get_platdata(&pdev->dev);
1060 int ret; 1061 int ret;
1061 int i; 1062 int i;
1062 1063
1064 pr_err("U300 PMX PROBE\n");
1065
1063 /* Create state holders etc for this driver */ 1066 /* Create state holders etc for this driver */
1064 upmx = devm_kzalloc(&pdev->dev, sizeof(*upmx), GFP_KERNEL); 1067 upmx = devm_kzalloc(&pdev->dev, sizeof(*upmx), GFP_KERNEL);
1065 if (!upmx) 1068 if (!upmx)
@@ -1095,12 +1098,14 @@ static int __init u300_pmx_probe(struct platform_device *pdev)
1095 } 1098 }
1096 1099
1097 /* We will handle a range of GPIO pins */ 1100 /* We will handle a range of GPIO pins */
1098 for (i = 0; i < ARRAY_SIZE(u300_gpio_ranges); i++) 1101 for (i = 0; i < ARRAY_SIZE(u300_gpio_ranges); i++) {
1102 u300_gpio_ranges[i].gc = gpio_chip;
1099 pinctrl_add_gpio_range(upmx->pctl, &u300_gpio_ranges[i]); 1103 pinctrl_add_gpio_range(upmx->pctl, &u300_gpio_ranges[i]);
1104 }
1100 1105
1101 platform_set_drvdata(pdev, upmx); 1106 platform_set_drvdata(pdev, upmx);
1102 1107
1103 dev_info(&pdev->dev, "initialized U300 pinmux driver\n"); 1108 dev_info(&pdev->dev, "initialized U300 pin control driver\n");
1104 1109
1105 return 0; 1110 return 0;
1106 1111
@@ -1115,7 +1120,7 @@ out_no_resource:
1115 return ret; 1120 return ret;
1116} 1121}
1117 1122
1118static int __exit u300_pmx_remove(struct platform_device *pdev) 1123static int __devexit u300_pmx_remove(struct platform_device *pdev)
1119{ 1124{
1120 struct u300_pmx *upmx = platform_get_drvdata(pdev); 1125 struct u300_pmx *upmx = platform_get_drvdata(pdev);
1121 int i; 1126 int i;
@@ -1136,12 +1141,13 @@ static struct platform_driver u300_pmx_driver = {
1136 .name = DRIVER_NAME, 1141 .name = DRIVER_NAME,
1137 .owner = THIS_MODULE, 1142 .owner = THIS_MODULE,
1138 }, 1143 },
1139 .remove = __exit_p(u300_pmx_remove), 1144 .probe = u300_pmx_probe,
1145 .remove = __devexit_p(u300_pmx_remove),
1140}; 1146};
1141 1147
1142static int __init u300_pmx_init(void) 1148static int __init u300_pmx_init(void)
1143{ 1149{
1144 return platform_driver_probe(&u300_pmx_driver, u300_pmx_probe); 1150 return platform_driver_register(&u300_pmx_driver);
1145} 1151}
1146arch_initcall(u300_pmx_init); 1152arch_initcall(u300_pmx_init);
1147 1153