2 * arch/ubicom32/mach-ip7k/board-ip7500iap.c
3 * Support for IP7500 Internet Audio Player
5 * This file supports the IP7500 Internet Audio Player:
8 * (C) Copyright 2009, Ubicom, Inc.
10 * This file is part of the Ubicom32 Linux Kernel Port.
12 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
13 * it and/or modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, either version 2 of the
15 * License, or (at your option) any later version.
17 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
18 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
19 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
20 * the GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with the Ubicom32 Linux Kernel Port. If not,
24 * see <http://www.gnu.org/licenses/>.
26 #include <linux/device.h>
27 #include <linux/gpio.h>
28 #include <asm/board.h>
30 #include <linux/delay.h>
32 #include <linux/platform_device.h>
33 #include <asm/audio.h>
34 #include <linux/i2c.h>
35 #include <linux/i2c-gpio.h>
37 #include <asm/ubicom32sd.h>
38 #include <asm/sd_tio.h>
40 #include <asm/ubicom32bl.h>
42 #include <asm/machdep.h>
44 /******************************************************************************
45 * SD/IO Port F (Slot 1) platform data
47 static struct resource ip7500iap_portf_sd_resources
[] = {
53 * The init routine will query the devtree and fill this in
55 .flags
= IORESOURCE_IRQ
,
63 * The init routine will query the devtree and fill this in
65 .flags
= IORESOURCE_IRQ
,
69 * Memory Mapped Registers
73 * The init routine will query the devtree and fill this in
75 .flags
= IORESOURCE_MEM
,
79 static struct ubicom32sd_card ip7500iap_portf_sd_cards
[] = {
88 static struct ubicom32sd_platform_data ip7500iap_portf_sd_platform_data
= {
90 .cards
= ip7500iap_portf_sd_cards
,
93 static struct platform_device ip7500iap_portf_sd_device
= {
96 .resource
= ip7500iap_portf_sd_resources
,
97 .num_resources
= ARRAY_SIZE(ip7500iap_portf_sd_resources
),
99 .platform_data
= &ip7500iap_portf_sd_platform_data
,
105 * ip7500iap_portf_sd_init
107 static void ip7500iap_portf_sd_init(void)
110 * Check the device tree for the sd_tio
112 struct sd_tio_node
*sd_node
= (struct sd_tio_node
*)devtree_find_node("portf_sd");
114 printk(KERN_INFO
"PortF SDTIO not found\n");
119 * Fill in the resources and platform data from devtree information
121 ip7500iap_portf_sd_resources
[0].start
= sd_node
->dn
.sendirq
;
122 ip7500iap_portf_sd_resources
[1].start
= sd_node
->dn
.recvirq
;
123 ip7500iap_portf_sd_resources
[2].start
= (u32_t
)&(sd_node
->regs
);
124 ip7500iap_portf_sd_resources
[2].end
= (u32_t
)&(sd_node
->regs
) + sizeof(sd_node
->regs
);
126 platform_device_register(&ip7500iap_portf_sd_device
);
129 /******************************************************************************
130 * SD/IO Port B (Slot 2) platform data
132 static struct resource ip7500iap_portb_sd_resources
[] = {
138 * The init routine will query the devtree and fill this in
140 .flags
= IORESOURCE_IRQ
,
148 * The init routine will query the devtree and fill this in
150 .flags
= IORESOURCE_IRQ
,
154 * Memory Mapped Registers
158 * The init routine will query the devtree and fill this in
160 .flags
= IORESOURCE_MEM
,
164 static struct ubicom32sd_card ip7500iap_portb_sd_cards
[] = {
166 .pin_wp
= GPIO_RB_13
,
168 .pin_pwr
= GPIO_RB_11
,
169 .pin_cd
= GPIO_RB_12
,
173 static struct ubicom32sd_platform_data ip7500iap_portb_sd_platform_data
= {
175 .cards
= ip7500iap_portb_sd_cards
,
178 static struct platform_device ip7500iap_portb_sd_device
= {
179 .name
= "ubicom32sd",
181 .resource
= ip7500iap_portb_sd_resources
,
182 .num_resources
= ARRAY_SIZE(ip7500iap_portb_sd_resources
),
184 .platform_data
= &ip7500iap_portb_sd_platform_data
,
190 * ip7500iap_portb_sd_init
192 static void ip7500iap_portb_sd_init(void)
195 * Check the device tree for the sd_tio
197 struct sd_tio_node
*sd_node
= (struct sd_tio_node
*)devtree_find_node("portb_sd");
199 printk(KERN_INFO
"PortB SDTIO not found\n");
204 * Fill in the resources and platform data from devtree information
206 ip7500iap_portb_sd_resources
[0].start
= sd_node
->dn
.sendirq
;
207 ip7500iap_portb_sd_resources
[1].start
= sd_node
->dn
.recvirq
;
208 ip7500iap_portb_sd_resources
[2].start
= (u32_t
)&(sd_node
->regs
);
209 ip7500iap_portb_sd_resources
[2].end
= (u32_t
)&(sd_node
->regs
) + sizeof(sd_node
->regs
);
211 platform_device_register(&ip7500iap_portb_sd_device
);
214 /******************************************************************************
217 * Connected via I2C bus, interrupt on PA6
219 #include <linux/i2c/tsc2007.h>
222 * ip7500iap_tsc2007_exit_platform_hw
224 static void ip7500iap_tsc2007_exit_platform_hw(void)
226 UBICOM32_IO_PORT(RA
)->ctl0
&= ~(0x03 << 19);
227 gpio_free(GPIO_RA_6
);
231 * ip7500iap_tsc2007_init_platform_hw
233 static int ip7500iap_tsc2007_init_platform_hw(void)
235 int res
= gpio_request(GPIO_RA_6
, "TSC2007_IRQ");
240 UBICOM32_IO_PORT(RA
)->ctl0
&= ~(0x03 << 19);
241 UBICOM32_IO_PORT(RA
)->ctl0
|= (0x02 << 19);
246 * ip7500iap_tsc2007_get_pendown_state
248 static int ip7500iap_tsc2007_get_pendown_state(void)
250 return !gpio_get_value(GPIO_RA_6
);
253 static struct tsc2007_platform_data ip7500iap_tsc2007_data
= {
256 .get_pendown_state
= ip7500iap_tsc2007_get_pendown_state
,
257 .init_platform_hw
= ip7500iap_tsc2007_init_platform_hw
,
258 .exit_platform_hw
= ip7500iap_tsc2007_exit_platform_hw
,
261 /******************************************************************************
264 * DO NOT CHANGE THE ORDER HERE unless you know how this works. There
265 * are hardcoded indicies which refer to the order of drivers listed here.
267 static struct i2c_board_info __initdata ip7500iap_i2c_board_info
[] = {
269 * U6, CS4350 DAC, address 0x4B
277 * U20, S35390A RTC, address 0x30
285 * U9, TSC2007 Touch screen controller, address 0x49, irq RA6
291 .platform_data
= &ip7500iap_tsc2007_data
,
296 * I2C bus on the board, SDA PE4, SCL PE5
298 static struct i2c_gpio_platform_data ip7500iap_i2c_data
= {
299 .sda_pin
= GPIO_RF_14
,
300 .scl_pin
= GPIO_RF_13
,
301 .sda_is_open_drain
= 0,
302 .scl_is_open_drain
= 0,
306 static struct platform_device ip7500iap_i2c_device
= {
310 .platform_data
= &ip7500iap_i2c_data
,
314 /******************************************************************************
315 * Backlight on the board PD0, hardware PWM
317 static struct ubicom32bl_platform_data ip7500iap_backlight_data
= {
318 .type
= UBICOM32BL_TYPE_PWM
,
322 .default_intensity
= 0x80,
325 static struct platform_device ip7500iap_backlight_device
= {
326 .name
= "ubicom32bl",
329 .platform_data
= &ip7500iap_backlight_data
,
333 /******************************************************************************
334 * Devices on this board
336 static struct platform_device
*ip7500iap_devices
[] __initdata
= {
337 &ip7500iap_i2c_device
,
338 &ip7500iap_backlight_device
,
342 * ip7500iap_power_off
343 * Called to turn the power off for this board
345 static void ip7500iap_power_off(void)
347 gpio_set_value(GPIO_RF_11
, 0);
352 * Called to add the devices which we have on this board
354 static int __init
ip7500iap_init(void)
356 struct platform_device
*audio_dev
;
357 struct platform_device
*audio_dev2
;
365 * Hold the POWER_HOLD line
367 ret
= gpio_request(GPIO_RF_11
, "POWER_HOLD");
369 printk(KERN_ERR
"%s: could not request POWER_HOLD GPIO\n", __FUNCTION__
);
371 gpio_direction_output(GPIO_RF_11
, 1);
372 mach_power_off
= ip7500iap_power_off
;
377 ret
= gpio_request(GPIO_RE_7
, "DAC_nRESET");
379 printk(KERN_ERR
"%s: could not request DAC_nRESET GPIO\n", __FUNCTION__
);
381 gpio_direction_output(GPIO_RE_7
, 0);
383 gpio_set_value(GPIO_RE_7
, 1);
386 * Bring up any SDIO slots
388 ip7500iap_portb_sd_init();
389 ip7500iap_portf_sd_init();
392 * Bring up audio devices
394 platform_add_devices(ip7500iap_devices
, ARRAY_SIZE(ip7500iap_devices
));
396 audio_dev
= audio_device_alloc("snd-ubi32-cs4350", "audio", "audio-i2sout", 0);
398 ip7500iap_i2c_board_info
[0].platform_data
= audio_dev
;
401 audio_dev2
= audio_device_alloc("snd-ubi32-generic", "audio", "audio-spdifout", 0);
403 platform_device_register(audio_dev2
);
406 printk(KERN_INFO
"%s: registering i2c resources\n", __FUNCTION__
);
407 i2c_register_board_info(0, ip7500iap_i2c_board_info
, ARRAY_SIZE(ip7500iap_i2c_board_info
));
409 printk(KERN_INFO
"IP7500 Internet Audio Player\n");
414 arch_initcall(ip7500iap_init
);