^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) // Copyright (c) 2006-2009 Victor Chukhantsev, Denis Grigoriev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) // Copyright (c) 2007-2010 Vasily Khoruzhick
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) // based on smdk2440 written by Ben Dooks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/memblock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/gpio/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/serial_core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/serial_s3c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/gpio_keys.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/pda_power.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/pwm_backlight.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/pwm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/s3c_adc_battery.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/mtd/mtd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/mtd/partitions.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/mmc/host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <asm/mach/map.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <linux/platform_data/i2c-s3c2410.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <linux/platform_data/mmc-s3cmci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <linux/platform_data/mtd-nand-s3c2410.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include <linux/platform_data/touchscreen-s3c2410.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include <linux/platform_data/usb-s3c2410_udc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #include <linux/platform_data/fb-s3c2410.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include <sound/uda1380.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #include "hardware-s3c24xx.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include "regs-gpio.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #include "gpio-samsung.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #include "cpu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #include "devs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #include "pm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #include "gpio-cfg.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #include "s3c24xx.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #include "h1940.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define LCD_PWM_PERIOD 192960
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define LCD_PWM_DUTY 127353
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static struct map_desc rx1950_iodesc[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static struct s3c2410_uartcfg rx1950_uartcfgs[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) [0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) .hwport = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) .flags = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) .ucon = 0x3c5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) .ulcon = 0x03,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) .ufcon = 0x51,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) .clk_sel = S3C2410_UCON_CLKSEL3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) [1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) .hwport = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) .flags = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) .ucon = 0x3c5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) .ulcon = 0x03,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) .ufcon = 0x51,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) .clk_sel = S3C2410_UCON_CLKSEL3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /* IR port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) [2] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) .hwport = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) .flags = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .ucon = 0x3c5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) .ulcon = 0x43,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) .ufcon = 0xf1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) .clk_sel = S3C2410_UCON_CLKSEL3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static struct s3c2410fb_display rx1950_display = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) .type = S3C2410_LCDCON1_TFT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) .width = 240,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) .height = 320,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) .xres = 240,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) .yres = 320,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) .bpp = 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) .pixclock = 260000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) .left_margin = 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .right_margin = 20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) .hsync_len = 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) .upper_margin = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) .lower_margin = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) .vsync_len = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) .lcdcon5 = S3C2410_LCDCON5_FRM565 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) S3C2410_LCDCON5_INVVCLK |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) S3C2410_LCDCON5_INVVLINE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) S3C2410_LCDCON5_INVVFRAME |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) S3C2410_LCDCON5_HWSWP |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) (0x02 << 13) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) (0x02 << 15),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static int power_supply_init(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) return gpio_request(S3C2410_GPF(2), "cable plugged");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static int rx1950_is_ac_online(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) return !gpio_get_value(S3C2410_GPF(2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static void power_supply_exit(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) gpio_free(S3C2410_GPF(2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static char *rx1950_supplicants[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) "main-battery"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static struct pda_power_pdata power_supply_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) .init = power_supply_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) .is_ac_online = rx1950_is_ac_online,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) .exit = power_supply_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) .supplied_to = rx1950_supplicants,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) .num_supplicants = ARRAY_SIZE(rx1950_supplicants),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static struct resource power_supply_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) [0] = DEFINE_RES_NAMED(IRQ_EINT2, 1, "ac", IORESOURCE_IRQ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) | IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static struct platform_device power_supply = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) .name = "pda-power",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) .id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) .platform_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) &power_supply_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) .resource = power_supply_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) .num_resources = ARRAY_SIZE(power_supply_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) { .volt = 4100, .cur = 156, .level = 100},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) { .volt = 4050, .cur = 156, .level = 95},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) { .volt = 4025, .cur = 141, .level = 90},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) { .volt = 3995, .cur = 144, .level = 85},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) { .volt = 3957, .cur = 162, .level = 80},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) { .volt = 3931, .cur = 147, .level = 75},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) { .volt = 3902, .cur = 147, .level = 70},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) { .volt = 3863, .cur = 153, .level = 65},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) { .volt = 3838, .cur = 150, .level = 60},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) { .volt = 3800, .cur = 153, .level = 55},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) { .volt = 3765, .cur = 153, .level = 50},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) { .volt = 3748, .cur = 172, .level = 45},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) { .volt = 3740, .cur = 153, .level = 40},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) { .volt = 3714, .cur = 175, .level = 35},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) { .volt = 3710, .cur = 156, .level = 30},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) { .volt = 3963, .cur = 156, .level = 25},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) { .volt = 3672, .cur = 178, .level = 20},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) { .volt = 3651, .cur = 178, .level = 15},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) { .volt = 3629, .cur = 178, .level = 10},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) { .volt = 3612, .cur = 162, .level = 5},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) { .volt = 3605, .cur = 162, .level = 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) { .volt = 4200, .cur = 0, .level = 100},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) { .volt = 4190, .cur = 0, .level = 99},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) { .volt = 4178, .cur = 0, .level = 95},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) { .volt = 4110, .cur = 0, .level = 70},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) { .volt = 4076, .cur = 0, .level = 65},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) { .volt = 4046, .cur = 0, .level = 60},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) { .volt = 4021, .cur = 0, .level = 55},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) { .volt = 3999, .cur = 0, .level = 50},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) { .volt = 3982, .cur = 0, .level = 45},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) { .volt = 3965, .cur = 0, .level = 40},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) { .volt = 3957, .cur = 0, .level = 35},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) { .volt = 3948, .cur = 0, .level = 30},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) { .volt = 3936, .cur = 0, .level = 25},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) { .volt = 3927, .cur = 0, .level = 20},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) { .volt = 3906, .cur = 0, .level = 15},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) { .volt = 3880, .cur = 0, .level = 10},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) { .volt = 3829, .cur = 0, .level = 5},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) { .volt = 3820, .cur = 0, .level = 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static int rx1950_bat_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) goto err_gpio1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) goto err_gpio2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) err_gpio2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) gpio_free(S3C2410_GPJ(2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) err_gpio1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static void rx1950_bat_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) gpio_free(S3C2410_GPJ(2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) gpio_free(S3C2410_GPJ(3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static void rx1950_enable_charger(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) gpio_direction_output(S3C2410_GPJ(2), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) gpio_direction_output(S3C2410_GPJ(3), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) static void rx1950_disable_charger(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) gpio_direction_output(S3C2410_GPJ(2), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) gpio_direction_output(S3C2410_GPJ(3), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) static DEFINE_SPINLOCK(rx1950_blink_spin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static int rx1950_led_blink_set(struct gpio_desc *desc, int state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) unsigned long *delay_on, unsigned long *delay_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) int gpio = desc_to_gpio(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) int blink_gpio, check_gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) switch (gpio) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) case S3C2410_GPA(6):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) blink_gpio = S3C2410_GPA(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) check_gpio = S3C2410_GPA(3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) case S3C2410_GPA(7):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) blink_gpio = S3C2410_GPA(3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) check_gpio = S3C2410_GPA(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) if (delay_on && delay_off && !*delay_on && !*delay_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) *delay_on = *delay_off = 500;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) spin_lock(&rx1950_blink_spin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) switch (state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) case GPIO_LED_NO_BLINK_LOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) case GPIO_LED_NO_BLINK_HIGH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) if (!gpio_get_value(check_gpio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) gpio_set_value(S3C2410_GPJ(6), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) gpio_set_value(blink_gpio, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) gpio_set_value(gpio, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) case GPIO_LED_BLINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) gpio_set_value(gpio, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) gpio_set_value(S3C2410_GPJ(6), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) gpio_set_value(blink_gpio, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) spin_unlock(&rx1950_blink_spin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) static struct gpio_led rx1950_leds_desc[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) .name = "Green",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) .default_trigger = "main-battery-full",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) .gpio = S3C2410_GPA(6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) .retain_state_suspended = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) .name = "Red",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) .default_trigger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) = "main-battery-charging-blink-full-solid",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) .gpio = S3C2410_GPA(7),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) .retain_state_suspended = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) .name = "Blue",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) .default_trigger = "rx1950-acx-mem",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) .gpio = S3C2410_GPA(11),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) .retain_state_suspended = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) static struct gpio_led_platform_data rx1950_leds_pdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) .num_leds = ARRAY_SIZE(rx1950_leds_desc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) .leds = rx1950_leds_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) .gpio_blink_set = rx1950_led_blink_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) static struct platform_device rx1950_leds = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) .name = "leds-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) .id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) .platform_data = &rx1950_leds_pdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static struct s3c_adc_bat_pdata rx1950_bat_cfg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) .init = rx1950_bat_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) .exit = rx1950_bat_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) .enable_charger = rx1950_enable_charger,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) .disable_charger = rx1950_disable_charger,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) .gpio_charge_finished = S3C2410_GPF(3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) .lut_noac = bat_lut_noac,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) .lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) .lut_acin = bat_lut_acin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) .lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) .volt_channel = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) .current_channel = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) .volt_mult = 4235,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) .current_mult = 2900,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) .internal_impedance = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) static struct platform_device rx1950_battery = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) .name = "s3c-adc-battery",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) .id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) .parent = &s3c_device_adc.dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) .platform_data = &rx1950_bat_cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) .displays = &rx1950_display,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) .num_displays = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) .default_display = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) .lpcsel = 0x02,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) .gpccon = 0xaa9556a9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) .gpccon_mask = 0xffc003fc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) .gpccon_reg = S3C2410_GPCCON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) .gpcup = 0x0000ffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) .gpcup_mask = 0xffffffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) .gpcup_reg = S3C2410_GPCUP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) .gpdcon = 0xaa90aaa1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) .gpdcon_mask = 0xffc0fff0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) .gpdcon_reg = S3C2410_GPDCON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) .gpdup = 0x0000fcfd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) .gpdup_mask = 0xffffffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) .gpdup_reg = S3C2410_GPDUP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) static struct pwm_lookup rx1950_pwm_lookup[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight.0", NULL, 48000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) PWM_POLARITY_NORMAL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) static struct pwm_device *lcd_pwm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) static struct pwm_state lcd_pwm_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) static void rx1950_lcd_power(int enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) static int enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) if (enabled == enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) if (!enable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) /* GPC11-GPC15->OUTPUT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) for (i = 11; i < 16; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) gpio_direction_output(S3C2410_GPC(i), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) /* Wait a bit here... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) mdelay(100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) /* GPD2-GPD7->OUTPUT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) /* GPD11-GPD15->OUTPUT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) /* GPD2-GPD7->1, GPD11-GPD15->1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) for (i = 2; i < 8; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) gpio_direction_output(S3C2410_GPD(i), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) for (i = 11; i < 16; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) gpio_direction_output(S3C2410_GPD(i), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) /* Wait a bit here...*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) mdelay(100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) /* GPB0->OUTPUT, GPB0->0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) gpio_direction_output(S3C2410_GPB(0), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) /* GPC1-GPC4->OUTPUT, GPC1-4->0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) for (i = 1; i < 5; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) gpio_direction_output(S3C2410_GPC(i), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) /* GPC15-GPC11->0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) for (i = 11; i < 16; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) gpio_direction_output(S3C2410_GPC(i), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) /* GPD15-GPD11->0, GPD2->GPD7->0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) for (i = 11; i < 16; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) gpio_direction_output(S3C2410_GPD(i), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) for (i = 2; i < 8; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) gpio_direction_output(S3C2410_GPD(i), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) /* GPC6->0, GPC7->0, GPC5->0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) gpio_direction_output(S3C2410_GPC(6), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) gpio_direction_output(S3C2410_GPC(7), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) gpio_direction_output(S3C2410_GPC(5), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) /* GPB1->OUTPUT, GPB1->0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) gpio_direction_output(S3C2410_GPB(1), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) lcd_pwm_state.enabled = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) pwm_apply_state(lcd_pwm, &lcd_pwm_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) /* GPC0->0, GPC10->0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) gpio_direction_output(S3C2410_GPC(0), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) gpio_direction_output(S3C2410_GPC(10), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) lcd_pwm_state.enabled = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) pwm_apply_state(lcd_pwm, &lcd_pwm_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) gpio_direction_output(S3C2410_GPC(0), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) gpio_direction_output(S3C2410_GPC(5), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) s3c_gpio_cfgpin(S3C2410_GPB(1), S3C2410_GPB1_TOUT1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) gpio_direction_output(S3C2410_GPC(7), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) for (i = 1; i < 5; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) for (i = 11; i < 16; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) for (i = 2; i < 8; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) for (i = 11; i < 16; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) gpio_direction_output(S3C2410_GPC(10), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) gpio_direction_output(S3C2410_GPC(6), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) enabled = enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) static void rx1950_bl_power(int enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) static int enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) if (enabled == enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) if (!enable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) gpio_direction_output(S3C2410_GPB(0), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) /* LED driver need a "push" to power on */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) gpio_direction_output(S3C2410_GPB(0), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) /* Warm up backlight for one period of PWM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) * Without this trick its almost impossible to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) * enable backlight with low brightness value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) ndelay(48000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) enabled = enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) static int rx1950_backlight_init(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) WARN_ON(gpio_request(S3C2410_GPB(0), "Backlight"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) lcd_pwm = pwm_request(1, "RX1950 LCD");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) if (IS_ERR(lcd_pwm)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) dev_err(dev, "Unable to request PWM for LCD power!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) return PTR_ERR(lcd_pwm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) * This is only required to initialize .polarity; all other values are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) * fixed in this driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) pwm_init_state(lcd_pwm, &lcd_pwm_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) lcd_pwm_state.period = LCD_PWM_PERIOD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) lcd_pwm_state.duty_cycle = LCD_PWM_DUTY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) rx1950_lcd_power(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) rx1950_bl_power(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) static void rx1950_backlight_exit(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) rx1950_bl_power(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) rx1950_lcd_power(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) pwm_free(lcd_pwm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) gpio_free(S3C2410_GPB(0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) static int rx1950_backlight_notify(struct device *dev, int brightness)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) if (!brightness) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) rx1950_bl_power(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) rx1950_lcd_power(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) rx1950_lcd_power(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) rx1950_bl_power(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) return brightness;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) static struct platform_pwm_backlight_data rx1950_backlight_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) .max_brightness = 24,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) .dft_brightness = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) .init = rx1950_backlight_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) .notify = rx1950_backlight_notify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) .exit = rx1950_backlight_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) static struct platform_device rx1950_backlight = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) .name = "pwm-backlight",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) .parent = &samsung_device_pwm.dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) .platform_data = &rx1950_backlight_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) s3c24xx_mci_def_set_power(power_mode, vdd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) switch (power_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) case MMC_POWER_OFF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) gpio_direction_output(S3C2410_GPJ(1), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) case MMC_POWER_UP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) case MMC_POWER_ON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) gpio_direction_output(S3C2410_GPJ(1), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) .set_power = rx1950_set_mmc_power,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) .ocr_avail = MMC_VDD_32_33,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) static struct gpiod_lookup_table rx1950_mmc_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) .dev_id = "s3c2410-sdi",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) .table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) /* Card detect S3C2410_GPF(5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) /* Write protect S3C2410_GPH(8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) /* bus pins */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) static struct mtd_partition rx1950_nand_part[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) [0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) .name = "Boot0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) .offset = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) .size = 0x4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) .mask_flags = MTD_WRITEABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) [1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) .name = "Boot1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) .offset = MTDPART_OFS_APPEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) .size = 0x40000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) .mask_flags = MTD_WRITEABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) [2] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) .name = "Kernel",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) .offset = MTDPART_OFS_APPEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) .size = 0x300000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) .mask_flags = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) [3] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) .name = "Filesystem",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) .offset = MTDPART_OFS_APPEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) .size = MTDPART_SIZ_FULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) .mask_flags = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) static struct s3c2410_nand_set rx1950_nand_sets[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) [0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) .name = "Internal",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) .nr_chips = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) .nr_partitions = ARRAY_SIZE(rx1950_nand_part),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) .partitions = rx1950_nand_part,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) static struct s3c2410_platform_nand rx1950_nand_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) .tacls = 25,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) .twrph0 = 50,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) .twrph1 = 15,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) .nr_sets = ARRAY_SIZE(rx1950_nand_sets),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) .sets = rx1950_nand_sets,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) .engine_type = NAND_ECC_ENGINE_TYPE_SOFT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) static struct s3c2410_udc_mach_info rx1950_udc_cfg __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) .vbus_pin = S3C2410_GPG(5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) .vbus_pin_inverted = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) .pullup_pin = S3C2410_GPJ(5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) static struct s3c2410_ts_mach_info rx1950_ts_cfg __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) .delay = 10000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) .presc = 49,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) .oversampling_shift = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) static struct gpio_keys_button rx1950_gpio_keys_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) .code = KEY_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) .gpio = S3C2410_GPF(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) .desc = "Power button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) .wakeup = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) .code = KEY_F5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) .gpio = S3C2410_GPF(7),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) .desc = "Record button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) .code = KEY_F1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) .gpio = S3C2410_GPG(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) .desc = "Calendar button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) .code = KEY_F2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) .gpio = S3C2410_GPG(2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) .desc = "Contacts button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) .code = KEY_F3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) .gpio = S3C2410_GPG(3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) .desc = "Mail button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) .code = KEY_F4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) .gpio = S3C2410_GPG(7),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) .desc = "WLAN button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) .code = KEY_LEFT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) .gpio = S3C2410_GPG(10),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) .desc = "Left button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) .code = KEY_RIGHT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) .gpio = S3C2410_GPG(11),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) .desc = "Right button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) .code = KEY_UP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) .gpio = S3C2410_GPG(4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) .desc = "Up button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) .code = KEY_DOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) .gpio = S3C2410_GPG(6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) .desc = "Down button",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) .code = KEY_ENTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) .gpio = S3C2410_GPG(9),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) .active_low = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) .desc = "Ok button"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) static struct gpio_keys_platform_data rx1950_gpio_keys_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) .buttons = rx1950_gpio_keys_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) .nbuttons = ARRAY_SIZE(rx1950_gpio_keys_table),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) static struct platform_device rx1950_device_gpiokeys = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) .name = "gpio-keys",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) .dev.platform_data = &rx1950_gpio_keys_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) static struct uda1380_platform_data uda1380_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) .gpio_power = S3C2410_GPJ(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) .gpio_reset = S3C2410_GPD(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) .dac_clk = UDA1380_DAC_CLK_SYSCLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) static struct i2c_board_info rx1950_i2c_devices[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) I2C_BOARD_INFO("uda1380", 0x1a),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) .platform_data = &uda1380_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) static struct gpiod_lookup_table rx1950_audio_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) .dev_id = "rx1950-audio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) .table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) GPIO_LOOKUP("GPIOG", 12, "hp-gpio", GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) GPIO_LOOKUP("GPIOA", 1, "speaker-power", GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) static struct platform_device rx1950_audio = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) .name = "rx1950-audio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) .id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) static struct platform_device *rx1950_devices[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) &s3c2410_device_dclk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) &s3c_device_lcd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) &s3c_device_wdt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) &s3c_device_i2c0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) &s3c_device_iis,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) &s3c_device_usbgadget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) &s3c_device_rtc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) &s3c_device_nand,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) &s3c_device_sdi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) &s3c_device_adc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) &s3c_device_ts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) &samsung_device_pwm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) &rx1950_backlight,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) &rx1950_device_gpiokeys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) &power_supply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) &rx1950_battery,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) &rx1950_leds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) &rx1950_audio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) static void __init rx1950_map_io(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) s3c24xx_init_io(rx1950_iodesc, ARRAY_SIZE(rx1950_iodesc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) s3c24xx_init_uarts(rx1950_uartcfgs, ARRAY_SIZE(rx1950_uartcfgs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) s3c24xx_set_timer_source(S3C24XX_PWM3, S3C24XX_PWM4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) /* setup PM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) #ifdef CONFIG_PM_H1940
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) s3c_pm_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) static void __init rx1950_init_time(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) s3c2442_init_clocks(16934000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) s3c24xx_timer_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) static void __init rx1950_init_machine(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) s3c24xx_fb_set_platdata(&rx1950_lcd_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) s3c24xx_udc_set_platdata(&rx1950_udc_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) s3c24xx_ts_set_platdata(&rx1950_ts_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) gpiod_add_lookup_table(&rx1950_mmc_gpio_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) s3c24xx_mci_set_platdata(&rx1950_mmc_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) s3c_i2c0_set_platdata(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) s3c_nand_set_platdata(&rx1950_nand_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) /* Turn off suspend on both USB ports, and switch the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) * selectable USB port to USB device mode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) S3C2410_MISCCR_USBSUSPND0 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) S3C2410_MISCCR_USBSUSPND1, 0x0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) /* mmc power is disabled by default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) WARN_ON(gpio_request(S3C2410_GPJ(1), "MMC power"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) gpio_direction_output(S3C2410_GPJ(1), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) for (i = 0; i < 8; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) for (i = 10; i < 16; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) for (i = 2; i < 8; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) for (i = 11; i < 16; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) WARN_ON(gpio_request(S3C2410_GPA(3), "Red blink"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) WARN_ON(gpio_request(S3C2410_GPA(4), "Green blink"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) WARN_ON(gpio_request(S3C2410_GPJ(6), "LED blink"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) gpio_direction_output(S3C2410_GPA(3), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) gpio_direction_output(S3C2410_GPA(4), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) gpio_direction_output(S3C2410_GPJ(6), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) pwm_add_table(rx1950_pwm_lookup, ARRAY_SIZE(rx1950_pwm_lookup));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) gpiod_add_lookup_table(&rx1950_audio_gpio_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) /* Configure the I2S pins (GPE0...GPE4) in correct mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) S3C_GPIO_PULL_NONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) i2c_register_board_info(0, rx1950_i2c_devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) ARRAY_SIZE(rx1950_i2c_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) /* H1940 and RX3715 need to reserve this for suspend */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) static void __init rx1950_reserve(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) memblock_reserve(0x30003000, 0x1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) memblock_reserve(0x30081000, 0x1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) MACHINE_START(RX1950, "HP iPAQ RX1950")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) /* Maintainers: Vasily Khoruzhick */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) .atag_offset = 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) .map_io = rx1950_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) .reserve = rx1950_reserve,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) .init_irq = s3c2442_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) .init_machine = rx1950_init_machine,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) .init_time = rx1950_init_time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) MACHINE_END