diff options
Diffstat (limited to 'arch/arm/mach-omap2/common-board-devices.c')
-rw-r--r-- | arch/arm/mach-omap2/common-board-devices.c | 80 |
1 files changed, 20 insertions, 60 deletions
diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c index 48daac2581b4..d246efd9f734 100644 --- a/arch/arm/mach-omap2/common-board-devices.c +++ b/arch/arm/mach-omap2/common-board-devices.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/spi/ads7846.h> | 25 | #include <linux/spi/ads7846.h> |
26 | 26 | ||
27 | #include <linux/platform_data/spi-omap2-mcspi.h> | 27 | #include <linux/platform_data/spi-omap2-mcspi.h> |
28 | #include <linux/platform_data/mtd-nand-omap2.h> | ||
29 | 28 | ||
30 | #include "common.h" | 29 | #include "common.h" |
31 | #include "common-board-devices.h" | 30 | #include "common-board-devices.h" |
@@ -64,30 +63,36 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce, | |||
64 | struct spi_board_info *spi_bi = &ads7846_spi_board_info; | 63 | struct spi_board_info *spi_bi = &ads7846_spi_board_info; |
65 | int err; | 64 | int err; |
66 | 65 | ||
67 | err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown"); | 66 | /* |
68 | if (err) { | 67 | * If a board defines get_pendown_state() function, request the pendown |
69 | pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err); | 68 | * GPIO and set the GPIO debounce time. |
70 | return; | 69 | * If a board does not define the get_pendown_state() function, then |
71 | } | 70 | * the ads7846 driver will setup the pendown GPIO itself. |
71 | */ | ||
72 | if (board_pdata && board_pdata->get_pendown_state) { | ||
73 | err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown"); | ||
74 | if (err) { | ||
75 | pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err); | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | if (gpio_debounce) | ||
80 | gpio_set_debounce(gpio_pendown, gpio_debounce); | ||
72 | 81 | ||
73 | if (gpio_debounce) | 82 | gpio_export(gpio_pendown, 0); |
74 | gpio_set_debounce(gpio_pendown, gpio_debounce); | 83 | } |
75 | 84 | ||
76 | spi_bi->bus_num = bus_num; | 85 | spi_bi->bus_num = bus_num; |
77 | spi_bi->irq = gpio_to_irq(gpio_pendown); | 86 | spi_bi->irq = gpio_to_irq(gpio_pendown); |
78 | 87 | ||
88 | ads7846_config.gpio_pendown = gpio_pendown; | ||
89 | |||
79 | if (board_pdata) { | 90 | if (board_pdata) { |
80 | board_pdata->gpio_pendown = gpio_pendown; | 91 | board_pdata->gpio_pendown = gpio_pendown; |
92 | board_pdata->gpio_pendown_debounce = gpio_debounce; | ||
81 | spi_bi->platform_data = board_pdata; | 93 | spi_bi->platform_data = board_pdata; |
82 | if (board_pdata->get_pendown_state) | ||
83 | gpio_export(gpio_pendown, 0); | ||
84 | } else { | ||
85 | ads7846_config.gpio_pendown = gpio_pendown; | ||
86 | } | 94 | } |
87 | 95 | ||
88 | if (!board_pdata || (board_pdata && !board_pdata->get_pendown_state)) | ||
89 | gpio_free(gpio_pendown); | ||
90 | |||
91 | spi_register_board_info(&ads7846_spi_board_info, 1); | 96 | spi_register_board_info(&ads7846_spi_board_info, 1); |
92 | } | 97 | } |
93 | #else | 98 | #else |
@@ -96,48 +101,3 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce, | |||
96 | { | 101 | { |
97 | } | 102 | } |
98 | #endif | 103 | #endif |
99 | |||
100 | #if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE) | ||
101 | static struct omap_nand_platform_data nand_data; | ||
102 | |||
103 | void __init omap_nand_flash_init(int options, struct mtd_partition *parts, | ||
104 | int nr_parts) | ||
105 | { | ||
106 | u8 cs = 0; | ||
107 | u8 nandcs = GPMC_CS_NUM + 1; | ||
108 | |||
109 | /* find out the chip-select on which NAND exists */ | ||
110 | while (cs < GPMC_CS_NUM) { | ||
111 | u32 ret = 0; | ||
112 | ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); | ||
113 | |||
114 | if ((ret & 0xC00) == 0x800) { | ||
115 | printk(KERN_INFO "Found NAND on CS%d\n", cs); | ||
116 | if (nandcs > GPMC_CS_NUM) | ||
117 | nandcs = cs; | ||
118 | } | ||
119 | cs++; | ||
120 | } | ||
121 | |||
122 | if (nandcs > GPMC_CS_NUM) { | ||
123 | pr_info("NAND: Unable to find configuration in GPMC\n"); | ||
124 | return; | ||
125 | } | ||
126 | |||
127 | if (nandcs < GPMC_CS_NUM) { | ||
128 | nand_data.cs = nandcs; | ||
129 | nand_data.parts = parts; | ||
130 | nand_data.nr_parts = nr_parts; | ||
131 | nand_data.devsize = options; | ||
132 | |||
133 | printk(KERN_INFO "Registering NAND on CS%d\n", nandcs); | ||
134 | if (gpmc_nand_init(&nand_data) < 0) | ||
135 | printk(KERN_ERR "Unable to register NAND device\n"); | ||
136 | } | ||
137 | } | ||
138 | #else | ||
139 | void __init omap_nand_flash_init(int options, struct mtd_partition *parts, | ||
140 | int nr_parts) | ||
141 | { | ||
142 | } | ||
143 | #endif | ||