diff options
Diffstat (limited to 'arch/arm/mach-omap2/common-board-devices.c')
-rw-r--r-- | arch/arm/mach-omap2/common-board-devices.c | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c new file mode 100644 index 000000000000..e94903b2c65b --- /dev/null +++ b/arch/arm/mach-omap2/common-board-devices.c | |||
@@ -0,0 +1,163 @@ | |||
1 | /* | ||
2 | * common-board-devices.c | ||
3 | * | ||
4 | * Copyright (C) 2011 CompuLab, Ltd. | ||
5 | * Author: Mike Rapoport <mike@compulab.co.il> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/i2c.h> | ||
24 | #include <linux/i2c/twl.h> | ||
25 | |||
26 | #include <linux/gpio.h> | ||
27 | #include <linux/spi/spi.h> | ||
28 | #include <linux/spi/ads7846.h> | ||
29 | |||
30 | #include <plat/i2c.h> | ||
31 | #include <plat/mcspi.h> | ||
32 | #include <plat/nand.h> | ||
33 | |||
34 | #include "common-board-devices.h" | ||
35 | |||
36 | static struct i2c_board_info __initdata pmic_i2c_board_info = { | ||
37 | .addr = 0x48, | ||
38 | .flags = I2C_CLIENT_WAKE, | ||
39 | }; | ||
40 | |||
41 | void __init omap_pmic_init(int bus, u32 clkrate, | ||
42 | const char *pmic_type, int pmic_irq, | ||
43 | struct twl4030_platform_data *pmic_data) | ||
44 | { | ||
45 | strncpy(pmic_i2c_board_info.type, pmic_type, | ||
46 | sizeof(pmic_i2c_board_info.type)); | ||
47 | pmic_i2c_board_info.irq = pmic_irq; | ||
48 | pmic_i2c_board_info.platform_data = pmic_data; | ||
49 | |||
50 | omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1); | ||
51 | } | ||
52 | |||
53 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \ | ||
54 | defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) | ||
55 | static struct omap2_mcspi_device_config ads7846_mcspi_config = { | ||
56 | .turbo_mode = 0, | ||
57 | .single_channel = 1, /* 0: slave, 1: master */ | ||
58 | }; | ||
59 | |||
60 | static struct ads7846_platform_data ads7846_config = { | ||
61 | .x_max = 0x0fff, | ||
62 | .y_max = 0x0fff, | ||
63 | .x_plate_ohms = 180, | ||
64 | .pressure_max = 255, | ||
65 | .debounce_max = 10, | ||
66 | .debounce_tol = 3, | ||
67 | .debounce_rep = 1, | ||
68 | .gpio_pendown = -EINVAL, | ||
69 | .keep_vref_on = 1, | ||
70 | }; | ||
71 | |||
72 | static struct spi_board_info ads7846_spi_board_info __initdata = { | ||
73 | .modalias = "ads7846", | ||
74 | .bus_num = -EINVAL, | ||
75 | .chip_select = 0, | ||
76 | .max_speed_hz = 1500000, | ||
77 | .controller_data = &ads7846_mcspi_config, | ||
78 | .irq = -EINVAL, | ||
79 | .platform_data = &ads7846_config, | ||
80 | }; | ||
81 | |||
82 | void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce, | ||
83 | struct ads7846_platform_data *board_pdata) | ||
84 | { | ||
85 | struct spi_board_info *spi_bi = &ads7846_spi_board_info; | ||
86 | int err; | ||
87 | |||
88 | err = gpio_request(gpio_pendown, "TS PenDown"); | ||
89 | if (err) { | ||
90 | pr_err("Could not obtain gpio for TS PenDown: %d\n", err); | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | gpio_direction_input(gpio_pendown); | ||
95 | gpio_export(gpio_pendown, 0); | ||
96 | |||
97 | if (gpio_debounce) | ||
98 | gpio_set_debounce(gpio_pendown, gpio_debounce); | ||
99 | |||
100 | ads7846_config.gpio_pendown = gpio_pendown; | ||
101 | |||
102 | spi_bi->bus_num = bus_num; | ||
103 | spi_bi->irq = OMAP_GPIO_IRQ(gpio_pendown); | ||
104 | |||
105 | if (board_pdata) | ||
106 | spi_bi->platform_data = board_pdata; | ||
107 | |||
108 | spi_register_board_info(&ads7846_spi_board_info, 1); | ||
109 | } | ||
110 | #else | ||
111 | void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce, | ||
112 | struct ads7846_platform_data *board_pdata) | ||
113 | { | ||
114 | } | ||
115 | #endif | ||
116 | |||
117 | #if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE) | ||
118 | static struct omap_nand_platform_data nand_data = { | ||
119 | .dma_channel = -1, /* disable DMA in OMAP NAND driver */ | ||
120 | }; | ||
121 | |||
122 | void __init omap_nand_flash_init(int options, struct mtd_partition *parts, | ||
123 | int nr_parts) | ||
124 | { | ||
125 | u8 cs = 0; | ||
126 | u8 nandcs = GPMC_CS_NUM + 1; | ||
127 | |||
128 | /* find out the chip-select on which NAND exists */ | ||
129 | while (cs < GPMC_CS_NUM) { | ||
130 | u32 ret = 0; | ||
131 | ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); | ||
132 | |||
133 | if ((ret & 0xC00) == 0x800) { | ||
134 | printk(KERN_INFO "Found NAND on CS%d\n", cs); | ||
135 | if (nandcs > GPMC_CS_NUM) | ||
136 | nandcs = cs; | ||
137 | } | ||
138 | cs++; | ||
139 | } | ||
140 | |||
141 | if (nandcs > GPMC_CS_NUM) { | ||
142 | printk(KERN_INFO "NAND: Unable to find configuration " | ||
143 | "in GPMC\n "); | ||
144 | return; | ||
145 | } | ||
146 | |||
147 | if (nandcs < GPMC_CS_NUM) { | ||
148 | nand_data.cs = nandcs; | ||
149 | nand_data.parts = parts; | ||
150 | nand_data.nr_parts = nr_parts; | ||
151 | nand_data.options = options; | ||
152 | |||
153 | printk(KERN_INFO "Registering NAND on CS%d\n", nandcs); | ||
154 | if (gpmc_nand_init(&nand_data) < 0) | ||
155 | printk(KERN_ERR "Unable to register NAND device\n"); | ||
156 | } | ||
157 | } | ||
158 | #else | ||
159 | void __init omap_nand_flash_init(int options, struct mtd_partition *parts, | ||
160 | int nr_parts) | ||
161 | { | ||
162 | } | ||
163 | #endif | ||