aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2012-01-27 09:52:32 -0500
committerShawn Guo <shawn.guo@linaro.org>2012-01-31 09:39:22 -0500
commitc5f98794f9d807c1d203468f8deb1b3524a95e67 (patch)
tree828821c17125e65dec9cef6cd3bbe90c0dbb87ee
parent9250bc8b76bd7e89a9891c9a862aa3eea7bcfb8e (diff)
ARM: mx28evk: Simplify GPIO requests
Requesting all the GPIOs on a single array (mx28evk_gpios[]) can make the error handling of gpio_requests much simpler. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
-rw-r--r--arch/arm/mach-mxs/mach-mx28evk.c72
1 files changed, 16 insertions, 56 deletions
diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c
index f1cbf34aeb44..816417608679 100644
--- a/arch/arm/mach-mxs/mach-mx28evk.c
+++ b/arch/arm/mach-mxs/mach-mx28evk.c
@@ -223,7 +223,6 @@ static const struct gpio_led_platform_data mx28evk_led_data __initconst = {
223/* fec */ 223/* fec */
224static void __init mx28evk_fec_reset(void) 224static void __init mx28evk_fec_reset(void)
225{ 225{
226 int ret;
227 struct clk *clk; 226 struct clk *clk;
228 227
229 /* Enable fec phy clock */ 228 /* Enable fec phy clock */
@@ -231,32 +230,7 @@ static void __init mx28evk_fec_reset(void)
231 if (!IS_ERR(clk)) 230 if (!IS_ERR(clk))
232 clk_prepare_enable(clk); 231 clk_prepare_enable(clk);
233 232
234 /* Power up fec phy */ 233 gpio_set_value(MX28EVK_FEC_PHY_RESET, 0);
235 ret = gpio_request(MX28EVK_FEC_PHY_POWER, "fec-phy-power");
236 if (ret) {
237 pr_err("Failed to request gpio fec-phy-%s: %d\n", "power", ret);
238 return;
239 }
240
241 ret = gpio_direction_output(MX28EVK_FEC_PHY_POWER, 0);
242 if (ret) {
243 pr_err("Failed to drive gpio fec-phy-%s: %d\n", "power", ret);
244 return;
245 }
246
247 /* Reset fec phy */
248 ret = gpio_request(MX28EVK_FEC_PHY_RESET, "fec-phy-reset");
249 if (ret) {
250 pr_err("Failed to request gpio fec-phy-%s: %d\n", "reset", ret);
251 return;
252 }
253
254 gpio_direction_output(MX28EVK_FEC_PHY_RESET, 0);
255 if (ret) {
256 pr_err("Failed to drive gpio fec-phy-%s: %d\n", "reset", ret);
257 return;
258 }
259
260 mdelay(1); 234 mdelay(1);
261 gpio_set_value(MX28EVK_FEC_PHY_RESET, 1); 235 gpio_set_value(MX28EVK_FEC_PHY_RESET, 1);
262} 236}
@@ -413,9 +387,14 @@ static void __init mx28evk_add_regulators(void)
413static void __init mx28evk_add_regulators(void) {} 387static void __init mx28evk_add_regulators(void) {}
414#endif 388#endif
415 389
416static struct gpio mx28evk_lcd_gpios[] = { 390static const struct gpio mx28evk_gpios[] __initconst = {
417 { MX28EVK_LCD_ENABLE, GPIOF_OUT_INIT_HIGH, "lcd-enable" }, 391 { MX28EVK_LCD_ENABLE, GPIOF_OUT_INIT_HIGH, "lcd-enable" },
418 { MX28EVK_BL_ENABLE, GPIOF_OUT_INIT_HIGH, "bl-enable" }, 392 { MX28EVK_BL_ENABLE, GPIOF_OUT_INIT_HIGH, "bl-enable" },
393 { MX28EVK_FLEXCAN_SWITCH, GPIOF_DIR_OUT, "flexcan-switch" },
394 { MX28EVK_MMC0_SLOT_POWER, GPIOF_OUT_INIT_LOW, "mmc0-slot-power" },
395 { MX28EVK_MMC1_SLOT_POWER, GPIOF_OUT_INIT_LOW, "mmc1-slot-power" },
396 { MX28EVK_FEC_PHY_POWER, GPIOF_OUT_INIT_LOW, "fec-phy-power" },
397 { MX28EVK_FEC_PHY_RESET, GPIOF_DIR_OUT, "fec-phy-reset" },
419}; 398};
420 399
421static const struct mxs_saif_platform_data 400static const struct mxs_saif_platform_data
@@ -443,25 +422,18 @@ static void __init mx28evk_init(void)
443 if (mx28evk_fec_get_mac()) 422 if (mx28evk_fec_get_mac())
444 pr_warn("%s: failed on fec mac setup\n", __func__); 423 pr_warn("%s: failed on fec mac setup\n", __func__);
445 424
425 ret = gpio_request_array(mx28evk_gpios, ARRAY_SIZE(mx28evk_gpios));
426 if (ret)
427 pr_err("One or more GPIOs failed to be requested: %d\n", ret);
428
446 mx28evk_fec_reset(); 429 mx28evk_fec_reset();
447 mx28_add_fec(0, &mx28_fec_pdata[0]); 430 mx28_add_fec(0, &mx28_fec_pdata[0]);
448 mx28_add_fec(1, &mx28_fec_pdata[1]); 431 mx28_add_fec(1, &mx28_fec_pdata[1]);
449 432
450 ret = gpio_request_one(MX28EVK_FLEXCAN_SWITCH, GPIOF_DIR_OUT, 433 mx28_add_flexcan(0, &mx28evk_flexcan_pdata[0]);
451 "flexcan-switch"); 434 mx28_add_flexcan(1, &mx28evk_flexcan_pdata[1]);
452 if (ret) {
453 pr_err("failed to request gpio flexcan-switch: %d\n", ret);
454 } else {
455 mx28_add_flexcan(0, &mx28evk_flexcan_pdata[0]);
456 mx28_add_flexcan(1, &mx28evk_flexcan_pdata[1]);
457 }
458 435
459 ret = gpio_request_array(mx28evk_lcd_gpios, 436 mx28_add_mxsfb(&mx28evk_mxsfb_pdata);
460 ARRAY_SIZE(mx28evk_lcd_gpios));
461 if (ret)
462 pr_warn("failed to request gpio pins for lcd: %d\n", ret);
463 else
464 mx28_add_mxsfb(&mx28evk_mxsfb_pdata);
465 437
466 mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0); 438 mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0);
467 mx28_add_saif(0, &mx28evk_mxs_saif_pdata[0]); 439 mx28_add_saif(0, &mx28evk_mxs_saif_pdata[0]);
@@ -476,20 +448,8 @@ static void __init mx28evk_init(void)
476 mxs_add_platform_device("mxs-sgtl5000", 0, NULL, 0, 448 mxs_add_platform_device("mxs-sgtl5000", 0, NULL, 0,
477 NULL, 0); 449 NULL, 0);
478 450
479 /* power on mmc slot by writing 0 to the gpio */ 451 mx28_add_mxs_mmc(0, &mx28evk_mmc_pdata[0]);
480 ret = gpio_request_one(MX28EVK_MMC0_SLOT_POWER, GPIOF_OUT_INIT_LOW, 452 mx28_add_mxs_mmc(1, &mx28evk_mmc_pdata[1]);
481 "mmc0-slot-power");
482 if (ret)
483 pr_warn("failed to request gpio mmc0-slot-power: %d\n", ret);
484 else
485 mx28_add_mxs_mmc(0, &mx28evk_mmc_pdata[0]);
486
487 ret = gpio_request_one(MX28EVK_MMC1_SLOT_POWER, GPIOF_OUT_INIT_LOW,
488 "mmc1-slot-power");
489 if (ret)
490 pr_warn("failed to request gpio mmc1-slot-power: %d\n", ret);
491 else
492 mx28_add_mxs_mmc(1, &mx28evk_mmc_pdata[1]);
493 453
494 mx28_add_rtc_stmp3xxx(); 454 mx28_add_rtc_stmp3xxx();
495 455