diff options
| -rw-r--r-- | arch/arm/mach-s3c2440/mach-rx1950.c | 218 |
1 files changed, 212 insertions, 6 deletions
diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c index 32019bd9db3b..e0622bbb6dfa 100644 --- a/arch/arm/mach-s3c2440/mach-rx1950.c +++ b/arch/arm/mach-s3c2440/mach-rx1950.c | |||
| @@ -25,8 +25,12 @@ | |||
| 25 | #include <linux/input.h> | 25 | #include <linux/input.h> |
| 26 | #include <linux/gpio_keys.h> | 26 | #include <linux/gpio_keys.h> |
| 27 | #include <linux/sysdev.h> | 27 | #include <linux/sysdev.h> |
| 28 | #include <linux/pda_power.h> | ||
| 28 | #include <linux/pwm_backlight.h> | 29 | #include <linux/pwm_backlight.h> |
| 29 | #include <linux/pwm.h> | 30 | #include <linux/pwm.h> |
| 31 | #include <linux/s3c_adc_battery.h> | ||
| 32 | #include <linux/leds.h> | ||
| 33 | #include <linux/i2c.h> | ||
| 30 | 34 | ||
| 31 | #include <linux/mtd/mtd.h> | 35 | #include <linux/mtd/mtd.h> |
| 32 | #include <linux/mtd/partitions.h> | 36 | #include <linux/mtd/partitions.h> |
| @@ -55,6 +59,8 @@ | |||
| 55 | #include <plat/irq.h> | 59 | #include <plat/irq.h> |
| 56 | #include <plat/ts.h> | 60 | #include <plat/ts.h> |
| 57 | 61 | ||
| 62 | #include <sound/uda1380.h> | ||
| 63 | |||
| 58 | #define LCD_PWM_PERIOD 192960 | 64 | #define LCD_PWM_PERIOD 192960 |
| 59 | #define LCD_PWM_DUTY 127353 | 65 | #define LCD_PWM_DUTY 127353 |
| 60 | 66 | ||
| @@ -127,6 +133,193 @@ static struct s3c2410fb_display rx1950_display = { | |||
| 127 | 133 | ||
| 128 | }; | 134 | }; |
| 129 | 135 | ||
| 136 | static int power_supply_init(struct device *dev) | ||
| 137 | { | ||
| 138 | return gpio_request(S3C2410_GPF(2), "cable plugged"); | ||
| 139 | } | ||
| 140 | |||
| 141 | static int rx1950_is_ac_online(void) | ||
| 142 | { | ||
| 143 | return !gpio_get_value(S3C2410_GPF(2)); | ||
| 144 | } | ||
| 145 | |||
| 146 | static void power_supply_exit(struct device *dev) | ||
| 147 | { | ||
| 148 | gpio_free(S3C2410_GPF(2)); | ||
| 149 | } | ||
| 150 | |||
| 151 | static char *rx1950_supplicants[] = { | ||
| 152 | "main-battery" | ||
| 153 | }; | ||
| 154 | |||
| 155 | static struct pda_power_pdata power_supply_info = { | ||
| 156 | .init = power_supply_init, | ||
| 157 | .is_ac_online = rx1950_is_ac_online, | ||
| 158 | .exit = power_supply_exit, | ||
| 159 | .supplied_to = rx1950_supplicants, | ||
| 160 | .num_supplicants = ARRAY_SIZE(rx1950_supplicants), | ||
| 161 | }; | ||
| 162 | |||
| 163 | static struct resource power_supply_resources[] = { | ||
| 164 | [0] = { | ||
| 165 | .name = "ac", | ||
| 166 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE | | ||
| 167 | IORESOURCE_IRQ_HIGHEDGE, | ||
| 168 | .start = IRQ_EINT2, | ||
| 169 | .end = IRQ_EINT2, | ||
| 170 | }, | ||
| 171 | }; | ||
| 172 | |||
| 173 | static struct platform_device power_supply = { | ||
| 174 | .name = "pda-power", | ||
| 175 | .id = -1, | ||
| 176 | .dev = { | ||
| 177 | .platform_data = | ||
| 178 | &power_supply_info, | ||
| 179 | }, | ||
| 180 | .resource = power_supply_resources, | ||
| 181 | .num_resources = ARRAY_SIZE(power_supply_resources), | ||
| 182 | }; | ||
| 183 | |||
| 184 | static const struct s3c_adc_bat_thresh bat_lut_noac[] = { | ||
| 185 | { .volt = 4100, .cur = 156, .level = 100}, | ||
| 186 | { .volt = 4050, .cur = 156, .level = 95}, | ||
| 187 | { .volt = 4025, .cur = 141, .level = 90}, | ||
| 188 | { .volt = 3995, .cur = 144, .level = 85}, | ||
| 189 | { .volt = 3957, .cur = 162, .level = 80}, | ||
| 190 | { .volt = 3931, .cur = 147, .level = 75}, | ||
| 191 | { .volt = 3902, .cur = 147, .level = 70}, | ||
| 192 | { .volt = 3863, .cur = 153, .level = 65}, | ||
| 193 | { .volt = 3838, .cur = 150, .level = 60}, | ||
| 194 | { .volt = 3800, .cur = 153, .level = 55}, | ||
| 195 | { .volt = 3765, .cur = 153, .level = 50}, | ||
| 196 | { .volt = 3748, .cur = 172, .level = 45}, | ||
| 197 | { .volt = 3740, .cur = 153, .level = 40}, | ||
| 198 | { .volt = 3714, .cur = 175, .level = 35}, | ||
| 199 | { .volt = 3710, .cur = 156, .level = 30}, | ||
| 200 | { .volt = 3963, .cur = 156, .level = 25}, | ||
| 201 | { .volt = 3672, .cur = 178, .level = 20}, | ||
| 202 | { .volt = 3651, .cur = 178, .level = 15}, | ||
| 203 | { .volt = 3629, .cur = 178, .level = 10}, | ||
| 204 | { .volt = 3612, .cur = 162, .level = 5}, | ||
| 205 | { .volt = 3605, .cur = 162, .level = 0}, | ||
| 206 | }; | ||
| 207 | |||
| 208 | static const struct s3c_adc_bat_thresh bat_lut_acin[] = { | ||
| 209 | { .volt = 4200, .cur = 0, .level = 100}, | ||
| 210 | { .volt = 4190, .cur = 0, .level = 99}, | ||
| 211 | { .volt = 4178, .cur = 0, .level = 95}, | ||
| 212 | { .volt = 4110, .cur = 0, .level = 70}, | ||
| 213 | { .volt = 4076, .cur = 0, .level = 65}, | ||
| 214 | { .volt = 4046, .cur = 0, .level = 60}, | ||
| 215 | { .volt = 4021, .cur = 0, .level = 55}, | ||
| 216 | { .volt = 3999, .cur = 0, .level = 50}, | ||
| 217 | { .volt = 3982, .cur = 0, .level = 45}, | ||
| 218 | { .volt = 3965, .cur = 0, .level = 40}, | ||
| 219 | { .volt = 3957, .cur = 0, .level = 35}, | ||
| 220 | { .volt = 3948, .cur = 0, .level = 30}, | ||
| 221 | { .volt = 3936, .cur = 0, .level = 25}, | ||
| 222 | { .volt = 3927, .cur = 0, .level = 20}, | ||
| 223 | { .volt = 3906, .cur = 0, .level = 15}, | ||
| 224 | { .volt = 3880, .cur = 0, .level = 10}, | ||
| 225 | { .volt = 3829, .cur = 0, .level = 5}, | ||
| 226 | { .volt = 3820, .cur = 0, .level = 0}, | ||
| 227 | }; | ||
| 228 | |||
| 229 | int rx1950_bat_init(void) | ||
| 230 | { | ||
| 231 | int ret; | ||
| 232 | |||
| 233 | ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1"); | ||
| 234 | if (ret) | ||
| 235 | goto err_gpio1; | ||
| 236 | ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2"); | ||
| 237 | if (ret) | ||
| 238 | goto err_gpio2; | ||
| 239 | |||
| 240 | return 0; | ||
| 241 | |||
| 242 | err_gpio2: | ||
| 243 | gpio_free(S3C2410_GPJ(2)); | ||
| 244 | err_gpio1: | ||
| 245 | return ret; | ||
| 246 | } | ||
| 247 | |||
| 248 | void rx1950_bat_exit(void) | ||
| 249 | { | ||
| 250 | gpio_free(S3C2410_GPJ(2)); | ||
| 251 | gpio_free(S3C2410_GPJ(3)); | ||
| 252 | } | ||
| 253 | |||
| 254 | void rx1950_enable_charger(void) | ||
| 255 | { | ||
| 256 | gpio_direction_output(S3C2410_GPJ(2), 1); | ||
| 257 | gpio_direction_output(S3C2410_GPJ(3), 1); | ||
| 258 | } | ||
| 259 | |||
| 260 | void rx1950_disable_charger(void) | ||
| 261 | { | ||
| 262 | gpio_direction_output(S3C2410_GPJ(2), 0); | ||
| 263 | gpio_direction_output(S3C2410_GPJ(3), 0); | ||
| 264 | } | ||
| 265 | |||
| 266 | static struct gpio_led rx1950_leds_desc[] = { | ||
| 267 | { | ||
| 268 | .name = "Green", | ||
| 269 | .default_trigger = "main-battery-charging-or-full", | ||
| 270 | .gpio = S3C2410_GPA(6), | ||
| 271 | }, | ||
| 272 | { | ||
| 273 | .name = "Red", | ||
| 274 | .default_trigger = "main-battery-full", | ||
| 275 | .gpio = S3C2410_GPA(7), | ||
| 276 | }, | ||
| 277 | { | ||
| 278 | .name = "Blue", | ||
| 279 | .default_trigger = "rx1950-acx-mem", | ||
| 280 | .gpio = S3C2410_GPA(11), | ||
| 281 | }, | ||
| 282 | }; | ||
| 283 | |||
| 284 | static struct gpio_led_platform_data rx1950_leds_pdata = { | ||
| 285 | .num_leds = ARRAY_SIZE(rx1950_leds_desc), | ||
| 286 | .leds = rx1950_leds_desc, | ||
| 287 | }; | ||
| 288 | |||
| 289 | static struct platform_device rx1950_leds = { | ||
| 290 | .name = "leds-gpio", | ||
| 291 | .id = -1, | ||
| 292 | .dev = { | ||
| 293 | .platform_data = &rx1950_leds_pdata, | ||
| 294 | }, | ||
| 295 | }; | ||
| 296 | |||
| 297 | static struct s3c_adc_bat_pdata rx1950_bat_cfg = { | ||
| 298 | .init = rx1950_bat_init, | ||
| 299 | .exit = rx1950_bat_exit, | ||
| 300 | .enable_charger = rx1950_enable_charger, | ||
| 301 | .disable_charger = rx1950_disable_charger, | ||
| 302 | .gpio_charge_finished = S3C2410_GPF(3), | ||
| 303 | .lut_noac = bat_lut_noac, | ||
| 304 | .lut_noac_cnt = ARRAY_SIZE(bat_lut_noac), | ||
| 305 | .lut_acin = bat_lut_acin, | ||
| 306 | .lut_acin_cnt = ARRAY_SIZE(bat_lut_acin), | ||
| 307 | .volt_channel = 0, | ||
| 308 | .current_channel = 1, | ||
| 309 | .volt_mult = 4235, | ||
| 310 | .current_mult = 2900, | ||
| 311 | .internal_impedance = 200, | ||
| 312 | }; | ||
| 313 | |||
| 314 | static struct platform_device rx1950_battery = { | ||
| 315 | .name = "s3c-adc-battery", | ||
| 316 | .id = -1, | ||
| 317 | .dev = { | ||
| 318 | .parent = &s3c_device_adc.dev, | ||
| 319 | .platform_data = &rx1950_bat_cfg, | ||
| 320 | }, | ||
| 321 | }; | ||
| 322 | |||
| 130 | static struct s3c2410fb_mach_info rx1950_lcd_cfg = { | 323 | static struct s3c2410fb_mach_info rx1950_lcd_cfg = { |
| 131 | .displays = &rx1950_display, | 324 | .displays = &rx1950_display, |
| 132 | .num_displays = 1, | 325 | .num_displays = 1, |
| @@ -481,11 +674,17 @@ static struct platform_device rx1950_device_gpiokeys = { | |||
| 481 | .dev.platform_data = &rx1950_gpio_keys_data, | 674 | .dev.platform_data = &rx1950_gpio_keys_data, |
| 482 | }; | 675 | }; |
| 483 | 676 | ||
| 484 | static struct s3c2410_platform_i2c rx1950_i2c_data = { | 677 | static struct uda1380_platform_data uda1380_info = { |
| 485 | .flags = 0, | 678 | .gpio_power = S3C2410_GPJ(0), |
| 486 | .slave_addr = 0x42, | 679 | .gpio_reset = S3C2410_GPD(0), |
| 487 | .frequency = 400 * 1000, | 680 | .dac_clk = UDA1380_DAC_CLK_SYSCLK, |
| 488 | .sda_delay = S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON, | 681 | }; |
| 682 | |||
| 683 | static struct i2c_board_info rx1950_i2c_devices[] = { | ||
| 684 | { | ||
| 685 | I2C_BOARD_INFO("uda1380", 0x1a), | ||
| 686 | .platform_data = &uda1380_info, | ||
| 687 | }, | ||
| 489 | }; | 688 | }; |
| 490 | 689 | ||
| 491 | static struct platform_device *rx1950_devices[] __initdata = { | 690 | static struct platform_device *rx1950_devices[] __initdata = { |
| @@ -493,6 +692,7 @@ static struct platform_device *rx1950_devices[] __initdata = { | |||
| 493 | &s3c_device_wdt, | 692 | &s3c_device_wdt, |
| 494 | &s3c_device_i2c0, | 693 | &s3c_device_i2c0, |
| 495 | &s3c_device_iis, | 694 | &s3c_device_iis, |
| 695 | &s3c_device_pcm, | ||
| 496 | &s3c_device_usbgadget, | 696 | &s3c_device_usbgadget, |
| 497 | &s3c_device_rtc, | 697 | &s3c_device_rtc, |
| 498 | &s3c_device_nand, | 698 | &s3c_device_nand, |
| @@ -503,6 +703,9 @@ static struct platform_device *rx1950_devices[] __initdata = { | |||
| 503 | &s3c_device_timer[1], | 703 | &s3c_device_timer[1], |
| 504 | &rx1950_backlight, | 704 | &rx1950_backlight, |
| 505 | &rx1950_device_gpiokeys, | 705 | &rx1950_device_gpiokeys, |
| 706 | &power_supply, | ||
| 707 | &rx1950_battery, | ||
| 708 | &rx1950_leds, | ||
| 506 | }; | 709 | }; |
| 507 | 710 | ||
| 508 | static struct clk *rx1950_clocks[] __initdata = { | 711 | static struct clk *rx1950_clocks[] __initdata = { |
| @@ -538,7 +741,7 @@ static void __init rx1950_init_machine(void) | |||
| 538 | s3c24xx_udc_set_platdata(&rx1950_udc_cfg); | 741 | s3c24xx_udc_set_platdata(&rx1950_udc_cfg); |
| 539 | s3c24xx_ts_set_platdata(&rx1950_ts_cfg); | 742 | s3c24xx_ts_set_platdata(&rx1950_ts_cfg); |
| 540 | s3c24xx_mci_set_platdata(&rx1950_mmc_cfg); | 743 | s3c24xx_mci_set_platdata(&rx1950_mmc_cfg); |
| 541 | s3c_i2c0_set_platdata(&rx1950_i2c_data); | 744 | s3c_i2c0_set_platdata(NULL); |
| 542 | s3c_nand_set_platdata(&rx1950_nand_info); | 745 | s3c_nand_set_platdata(&rx1950_nand_info); |
| 543 | 746 | ||
| 544 | /* Turn off suspend on both USB ports, and switch the | 747 | /* Turn off suspend on both USB ports, and switch the |
| @@ -569,6 +772,9 @@ static void __init rx1950_init_machine(void) | |||
| 569 | WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power")); | 772 | WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power")); |
| 570 | 773 | ||
| 571 | platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices)); | 774 | platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices)); |
| 775 | |||
| 776 | i2c_register_board_info(0, rx1950_i2c_devices, | ||
| 777 | ARRAY_SIZE(rx1950_i2c_devices)); | ||
| 572 | } | 778 | } |
| 573 | 779 | ||
| 574 | /* H1940 and RX3715 need to reserve this for suspend */ | 780 | /* H1940 and RX3715 need to reserve this for suspend */ |
