This source file includes following definitions.
- nb0916_lcdcaseoff_handler
- nb0916_overheat_handler
- mach_nb0916_init
1
2
3
4
5
6
7
8
9
10
11 #include <linux/init.h>
12 #include <linux/device.h>
13 #include <linux/platform_device.h>
14 #include <linux/mtd/physmap.h>
15 #include <linux/io.h>
16 #include <linux/reboot.h>
17 #include <linux/interrupt.h>
18 #include <linux/i2c.h>
19 #include <linux/pwm.h>
20 #include <linux/pwm_backlight.h>
21 #include <linux/gpio.h>
22 #include <linux/gpio_keys.h>
23 #include <linux/input.h>
24
25 #include <mach/hardware.h>
26
27 static struct physmap_flash_data physmap_flash_data = {
28 .width = 1,
29 };
30
31 static struct resource physmap_flash_resource = {
32 .start = 0xFFF80000,
33 .end = 0xFFFFFFFF,
34 .flags = IORESOURCE_MEM,
35 };
36
37 static struct resource puv3_i2c_resources[] = {
38 [0] = {
39 .start = io_v2p(PKUNITY_I2C_BASE),
40 .end = io_v2p(PKUNITY_I2C_BASE) + 0xff,
41 .flags = IORESOURCE_MEM,
42 },
43 [1] = {
44 .start = IRQ_I2C,
45 .end = IRQ_I2C,
46 .flags = IORESOURCE_IRQ,
47 }
48 };
49
50 static struct pwm_lookup nb0916_pwm_lookup[] = {
51 PWM_LOOKUP("PKUnity-v3-PWM", 0, "pwm-backlight", NULL, 70 * 1024,
52 PWM_POLARITY_NORMAL),
53 };
54
55 static struct platform_pwm_backlight_data nb0916_backlight_data = {
56 .max_brightness = 100,
57 .dft_brightness = 100,
58 .enable_gpio = -1,
59 };
60
61 static struct gpio_keys_button nb0916_gpio_keys[] = {
62 {
63 .type = EV_KEY,
64 .code = KEY_POWER,
65 .gpio = GPI_SOFF_REQ,
66 .desc = "Power Button",
67 .wakeup = 1,
68 .active_low = 1,
69 },
70 {
71 .type = EV_KEY,
72 .code = BTN_TOUCH,
73 .gpio = GPI_BTN_TOUCH,
74 .desc = "Touchpad Button",
75 .wakeup = 1,
76 .active_low = 1,
77 },
78 };
79
80 static struct gpio_keys_platform_data nb0916_gpio_button_data = {
81 .buttons = nb0916_gpio_keys,
82 .nbuttons = ARRAY_SIZE(nb0916_gpio_keys),
83 };
84
85 static irqreturn_t nb0916_lcdcaseoff_handler(int irq, void *dev_id)
86 {
87 if (gpio_get_value(GPI_LCD_CASE_OFF))
88 gpio_set_value(GPO_LCD_EN, 1);
89 else
90 gpio_set_value(GPO_LCD_EN, 0);
91
92 return IRQ_HANDLED;
93 }
94
95 static irqreturn_t nb0916_overheat_handler(int irq, void *dev_id)
96 {
97 machine_halt();
98
99 return IRQ_HANDLED;
100 }
101
102 static struct i2c_board_info __initdata puv3_i2c_devices[] = {
103 { I2C_BOARD_INFO("lm75", I2C_TAR_THERMAL), },
104 { I2C_BOARD_INFO("bq27200", I2C_TAR_PWIC), },
105 { I2C_BOARD_INFO("24c02", I2C_TAR_EEPROM), },
106 };
107
108 int __init mach_nb0916_init(void)
109 {
110 i2c_register_board_info(0, puv3_i2c_devices,
111 ARRAY_SIZE(puv3_i2c_devices));
112
113 platform_device_register_simple("PKUnity-v3-I2C", -1,
114 puv3_i2c_resources, ARRAY_SIZE(puv3_i2c_resources));
115
116 pwm_add_table(nb0916_pwm_lookup, ARRAY_SIZE(nb0916_pwm_lookup));
117
118 platform_device_register_data(NULL, "pwm-backlight", -1,
119 &nb0916_backlight_data, sizeof(nb0916_backlight_data));
120
121 platform_device_register_data(NULL, "gpio-keys", -1,
122 &nb0916_gpio_button_data, sizeof(nb0916_gpio_button_data));
123
124 platform_device_register_resndata(NULL, "physmap-flash", -1,
125 &physmap_flash_resource, 1,
126 &physmap_flash_data, sizeof(physmap_flash_data));
127
128 if (request_irq(gpio_to_irq(GPI_LCD_CASE_OFF),
129 &nb0916_lcdcaseoff_handler,
130 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
131 "NB0916 lcd case off", NULL) < 0) {
132
133 printk(KERN_DEBUG "LCD-Case-OFF IRQ %d not available\n",
134 gpio_to_irq(GPI_LCD_CASE_OFF));
135 }
136
137 if (request_irq(gpio_to_irq(GPI_OTP_INT), &nb0916_overheat_handler,
138 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
139 "NB0916 overheating protection", NULL) < 0) {
140
141 printk(KERN_DEBUG "Overheating Protection IRQ %d not available\n",
142 gpio_to_irq(GPI_OTP_INT));
143 }
144
145 return 0;
146 }
147
148 subsys_initcall_sync(mach_nb0916_init);