aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap1/Makefile2
-rw-r--r--arch/arm/mach-omap1/board-sx1-mmc.c124
-rw-r--r--arch/arm/mach-omap1/board-sx1.c39
3 files changed, 139 insertions, 26 deletions
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index 416a778611b4..015a66b3ca8e 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -26,7 +26,7 @@ obj-$(CONFIG_MACH_OMAP_PALMZ71) += board-palmz71.o
26obj-$(CONFIG_MACH_OMAP_PALMTT) += board-palmtt.o 26obj-$(CONFIG_MACH_OMAP_PALMTT) += board-palmtt.o
27obj-$(CONFIG_MACH_NOKIA770) += board-nokia770.o 27obj-$(CONFIG_MACH_NOKIA770) += board-nokia770.o
28obj-$(CONFIG_MACH_AMS_DELTA) += board-ams-delta.o 28obj-$(CONFIG_MACH_AMS_DELTA) += board-ams-delta.o
29obj-$(CONFIG_MACH_SX1) += board-sx1.o 29obj-$(CONFIG_MACH_SX1) += board-sx1.o board-sx1-mmc.o
30 30
31ifeq ($(CONFIG_ARCH_OMAP15XX),y) 31ifeq ($(CONFIG_ARCH_OMAP15XX),y)
32# Innovator-1510 FPGA 32# Innovator-1510 FPGA
diff --git a/arch/arm/mach-omap1/board-sx1-mmc.c b/arch/arm/mach-omap1/board-sx1-mmc.c
new file mode 100644
index 000000000000..8c93d47719e8
--- /dev/null
+++ b/arch/arm/mach-omap1/board-sx1-mmc.c
@@ -0,0 +1,124 @@
1/*
2 * linux/arch/arm/mach-omap1/board-sx1-mmc.c
3 *
4 * Copyright (C) 2007 Instituto Nokia de Tecnologia - INdT
5 * Author: Carlos Eduardo Aguiar <carlos.aguiar@indt.org.br>
6 *
7 * This code is based on linux/arch/arm/mach-omap1/board-h2-mmc.c, which is:
8 * Copyright (C) 2007 Instituto Nokia de Tecnologia - INdT
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <asm/arch/hardware.h>
16#include <asm/arch/mmc.h>
17#include <asm/arch/gpio.h>
18
19#ifdef CONFIG_MMC_OMAP
20static int slot_cover_open;
21static struct device *mmc_device;
22
23static int sx1_mmc_set_power(struct device *dev, int slot, int power_on,
24 int vdd)
25{
26 int err;
27 u8 dat = 0;
28
29#ifdef CONFIG_MMC_DEBUG
30 dev_dbg(dev, "Set slot %d power: %s (vdd %d)\n", slot + 1,
31 power_on ? "on" : "off", vdd);
32#endif
33
34 if (slot != 0) {
35 dev_err(dev, "No such slot %d\n", slot + 1);
36 return -ENODEV;
37 }
38
39 err = sx1_i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat);
40 if (err < 0)
41 return err;
42
43 if (power_on)
44 dat |= SOFIA_MMC_POWER;
45 else
46 dat &= ~SOFIA_MMC_POWER;
47
48 return sx1_i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat);
49}
50
51static int sx1_mmc_set_bus_mode(struct device *dev, int slot, int bus_mode)
52{
53#ifdef CONFIG_MMC_DEBUG
54 dev_dbg(dev, "Set slot %d bus_mode %s\n", slot + 1,
55 bus_mode == MMC_BUSMODE_OPENDRAIN ? "open-drain" : "push-pull");
56#endif
57 if (slot != 0) {
58 dev_err(dev, "No such slot %d\n", slot + 1);
59 return -ENODEV;
60 }
61
62 return 0;
63}
64
65static int sx1_mmc_get_cover_state(struct device *dev, int slot)
66{
67 BUG_ON(slot != 0);
68
69 return slot_cover_open;
70}
71
72void sx1_mmc_slot_cover_handler(void *arg, int state)
73{
74 if (mmc_device == NULL)
75 return;
76
77 slot_cover_open = state;
78 omap_mmc_notify_cover_event(mmc_device, 0, state);
79}
80
81static int sx1_mmc_late_init(struct device *dev)
82{
83 int ret = 0;
84
85 mmc_device = dev;
86
87 return ret;
88}
89
90static void sx1_mmc_cleanup(struct device *dev)
91{
92}
93
94static struct omap_mmc_platform_data sx1_mmc_data = {
95 .nr_slots = 1,
96 .switch_slot = NULL,
97 .init = sx1_mmc_late_init,
98 .cleanup = sx1_mmc_cleanup,
99 .slots[0] = {
100 .set_power = sx1_mmc_set_power,
101 .set_bus_mode = sx1_mmc_set_bus_mode,
102 .get_ro = NULL,
103 .get_cover_state = sx1_mmc_get_cover_state,
104 .ocr_mask = MMC_VDD_28_29 | MMC_VDD_30_31 |
105 MMC_VDD_32_33 | MMC_VDD_33_34,
106 .name = "mmcblk",
107 },
108};
109
110void __init sx1_mmc_init(void)
111{
112 omap_set_mmc_info(1, &sx1_mmc_data);
113}
114
115#else
116
117void __init sx1_mmc_init(void)
118{
119}
120
121void sx1_mmc_slot_cover_handler(void *arg, int state)
122{
123}
124#endif
diff --git a/arch/arm/mach-omap1/board-sx1.c b/arch/arm/mach-omap1/board-sx1.c
index 2743d639aa05..be3ecd8c890e 100644
--- a/arch/arm/mach-omap1/board-sx1.c
+++ b/arch/arm/mach-omap1/board-sx1.c
@@ -44,7 +44,7 @@
44#include <asm/arch/keypad.h> 44#include <asm/arch/keypad.h>
45 45
46/* Write to I2C device */ 46/* Write to I2C device */
47int i2c_write_byte(u8 devaddr, u8 regoffset, u8 value) 47int sx1_i2c_write_byte(u8 devaddr, u8 regoffset, u8 value)
48{ 48{
49 struct i2c_adapter *adap; 49 struct i2c_adapter *adap;
50 int err; 50 int err;
@@ -67,7 +67,7 @@ int i2c_write_byte(u8 devaddr, u8 regoffset, u8 value)
67} 67}
68 68
69/* Read from I2C device */ 69/* Read from I2C device */
70int i2c_read_byte(u8 devaddr, u8 regoffset, u8 * value) 70int sx1_i2c_read_byte(u8 devaddr, u8 regoffset, u8 *value)
71{ 71{
72 struct i2c_adapter *adap; 72 struct i2c_adapter *adap;
73 int err; 73 int err;
@@ -101,66 +101,55 @@ int sx1_setkeylight(u8 keylight)
101{ 101{
102 if (keylight > SOFIA_MAX_LIGHT_VAL) 102 if (keylight > SOFIA_MAX_LIGHT_VAL)
103 keylight = SOFIA_MAX_LIGHT_VAL; 103 keylight = SOFIA_MAX_LIGHT_VAL;
104 return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_KEYLIGHT_REG, keylight); 104 return sx1_i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_KEYLIGHT_REG, keylight);
105} 105}
106/* get current keylight intensity */ 106/* get current keylight intensity */
107int sx1_getkeylight(u8 * keylight) 107int sx1_getkeylight(u8 * keylight)
108{ 108{
109 return i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_KEYLIGHT_REG, keylight); 109 return sx1_i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_KEYLIGHT_REG, keylight);
110} 110}
111/* set LCD backlight intensity */ 111/* set LCD backlight intensity */
112int sx1_setbacklight(u8 backlight) 112int sx1_setbacklight(u8 backlight)
113{ 113{
114 if (backlight > SOFIA_MAX_LIGHT_VAL) 114 if (backlight > SOFIA_MAX_LIGHT_VAL)
115 backlight = SOFIA_MAX_LIGHT_VAL; 115 backlight = SOFIA_MAX_LIGHT_VAL;
116 return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_BACKLIGHT_REG, backlight); 116 return sx1_i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_BACKLIGHT_REG,
117 backlight);
117} 118}
118/* get current LCD backlight intensity */ 119/* get current LCD backlight intensity */
119int sx1_getbacklight (u8 * backlight) 120int sx1_getbacklight (u8 * backlight)
120{ 121{
121 return i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_BACKLIGHT_REG, backlight); 122 return sx1_i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_BACKLIGHT_REG,
123 backlight);
122} 124}
123/* set LCD backlight power on/off */ 125/* set LCD backlight power on/off */
124int sx1_setmmipower(u8 onoff) 126int sx1_setmmipower(u8 onoff)
125{ 127{
126 int err; 128 int err;
127 u8 dat = 0; 129 u8 dat = 0;
128 err = i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat); 130 err = sx1_i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat);
129 if (err < 0) 131 if (err < 0)
130 return err; 132 return err;
131 if (onoff) 133 if (onoff)
132 dat |= SOFIA_MMILIGHT_POWER; 134 dat |= SOFIA_MMILIGHT_POWER;
133 else 135 else
134 dat &= ~SOFIA_MMILIGHT_POWER; 136 dat &= ~SOFIA_MMILIGHT_POWER;
135 return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat); 137 return sx1_i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat);
136}
137/* set MMC power on/off */
138int sx1_setmmcpower(u8 onoff)
139{
140 int err;
141 u8 dat = 0;
142 err = i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat);
143 if (err < 0)
144 return err;
145 if (onoff)
146 dat |= SOFIA_MMC_POWER;
147 else
148 dat &= ~SOFIA_MMC_POWER;
149 return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat);
150} 138}
139
151/* set USB power on/off */ 140/* set USB power on/off */
152int sx1_setusbpower(u8 onoff) 141int sx1_setusbpower(u8 onoff)
153{ 142{
154 int err; 143 int err;
155 u8 dat = 0; 144 u8 dat = 0;
156 err = i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat); 145 err = sx1_i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat);
157 if (err < 0) 146 if (err < 0)
158 return err; 147 return err;
159 if (onoff) 148 if (onoff)
160 dat |= SOFIA_USB_POWER; 149 dat |= SOFIA_USB_POWER;
161 else 150 else
162 dat &= ~SOFIA_USB_POWER; 151 dat &= ~SOFIA_USB_POWER;
163 return i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat); 152 return sx1_i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat);
164} 153}
165 154
166EXPORT_SYMBOL(sx1_setkeylight); 155EXPORT_SYMBOL(sx1_setkeylight);
@@ -168,7 +157,6 @@ EXPORT_SYMBOL(sx1_getkeylight);
168EXPORT_SYMBOL(sx1_setbacklight); 157EXPORT_SYMBOL(sx1_setbacklight);
169EXPORT_SYMBOL(sx1_getbacklight); 158EXPORT_SYMBOL(sx1_getbacklight);
170EXPORT_SYMBOL(sx1_setmmipower); 159EXPORT_SYMBOL(sx1_setmmipower);
171EXPORT_SYMBOL(sx1_setmmcpower);
172EXPORT_SYMBOL(sx1_setusbpower); 160EXPORT_SYMBOL(sx1_setusbpower);
173 161
174/*----------- Keypad -------------------------*/ 162/*----------- Keypad -------------------------*/
@@ -454,6 +442,7 @@ static void __init omap_sx1_init(void)
454 omap_board_config = sx1_config; 442 omap_board_config = sx1_config;
455 omap_board_config_size = ARRAY_SIZE(sx1_config); 443 omap_board_config_size = ARRAY_SIZE(sx1_config);
456 omap_serial_init(); 444 omap_serial_init();
445 sx1_mmc_init();
457 446
458 /* turn on USB power */ 447 /* turn on USB power */
459 /* sx1_setusbpower(1); cant do it here because i2c is not ready */ 448 /* sx1_setusbpower(1); cant do it here because i2c is not ready */