16 #include <linux/module.h>
20 #include <linux/i2c.h>
36 #if defined(CONFIG_INPUT_DM355EVM) || defined(CONFIG_INPUT_DM355EVM_MODULE)
37 #define msp_has_keyboard() true
39 #define msp_has_keyboard() false
42 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
43 #define msp_has_leds() true
45 #define msp_has_leds() false
48 #if defined(CONFIG_RTC_DRV_DM355EVM) || defined(CONFIG_RTC_DRV_DM355EVM_MODULE)
49 #define msp_has_rtc() true
51 #define msp_has_rtc() false
54 #if defined(CONFIG_VIDEO_TVP514X) || defined(CONFIG_VIDEO_TVP514X_MODULE)
55 #define msp_has_tvp() true
57 #define msp_has_tvp() false
98 #define MSP_GPIO(bit,reg) ((DM355EVM_MSP_ ## reg) << 3 | (bit))
100 static const u8 msp_gpios[] = {
123 #define MSP_GPIO_REG(offset) (msp_gpios[(offset)] >> 3)
124 #define MSP_GPIO_MASK(offset) BIT(msp_gpios[(offset)] & 0x07)
126 static int msp_gpio_in(
struct gpio_chip *
chip,
unsigned offset)
138 static u8 msp_led_cache;
140 static int msp_gpio_get(
struct gpio_chip *
chip,
unsigned offset)
153 static int msp_gpio_out(
struct gpio_chip *chip,
unsigned offset,
int value)
165 bits = msp_led_cache;
170 msp_led_cache =
bits;
175 static void msp_gpio_set(
struct gpio_chip *chip,
unsigned offset,
int value)
177 msp_gpio_out(chip, offset, value);
180 static struct gpio_chip dm355evm_msp_gpio = {
181 .label =
"dm355evm_msp",
183 .direction_input = msp_gpio_in,
185 .direction_output = msp_gpio_out,
195 void *
pdata,
unsigned pdata_len,
196 bool can_wakeup,
int irq)
209 pdev->
dev.parent = &client->
dev;
214 dev_dbg(&pdev->
dev,
"can't add platform_data\n");
237 dev_err(&client->
dev,
"can't add %s dev\n", name);
238 return ERR_PTR(status);
243 static int add_children(
struct i2c_client *client)
245 static const struct {
248 } config_inputs[] = {
254 { 8 + 4,
"NTSC/nPAL", },
262 dm355evm_msp_gpio.dev = &client->
dev;
269 #define GPIO_LED(l) .name = l, .active_low = true
270 static struct gpio_led evm_leds[] = {
272 .default_trigger =
"heartbeat", },
274 .default_trigger =
"mmc0", },
277 .default_trigger =
"mmc1", },
279 .default_trigger =
"nand-disk", },
293 evm_leds[i].
gpio = i + dm355evm_msp_gpio.base;
300 child = add_child(client,
"leds-gpio",
301 &evm_led_data,
sizeof(evm_led_data),
304 return PTR_ERR(child);
308 for (i = 0; i <
ARRAY_SIZE(config_inputs); i++) {
309 int gpio = dm355evm_msp_gpio.base + config_inputs[
i].offset;
314 gpio_export(gpio,
false);
318 if (client->
dev.platform_data) {
319 void (*mmcsd_setup)(unsigned) = client->
dev.platform_data;
321 mmcsd_setup(dm355evm_msp_gpio.base + 8 + 5);
326 child = add_child(client,
"rtc-dm355evm",
329 return PTR_ERR(child);
334 child = add_child(client,
"dm355evm_keys",
337 return PTR_ERR(child);
345 static void dm355evm_command(
unsigned command)
351 dev_err(&msp430->
dev,
"command %d failure %d\n",
355 static void dm355evm_power_off(
void)
360 static int dm355evm_msp_remove(
struct i2c_client *client)
371 const char *video =
msp_has_tvp() ?
"TVP5146" :
"imager";
381 dev_info(&client->
dev,
"firmware v.%02X, %s as video-in\n",
388 dev_warn(&client->
dev,
"error %d muxing %s as video-in\n",
392 msp_led_cache = 0xff;
396 status = add_children(client);
407 dm355evm_msp_remove(client);
412 {
"dm355evm_msp", 0 },
417 static struct i2c_driver dm355evm_msp_driver = {
418 .driver.name =
"dm355evm_msp",
419 .id_table = dm355evm_msp_ids,
420 .probe = dm355evm_msp_probe,
421 .remove = dm355evm_msp_remove,
424 static int __init dm355evm_msp_init(
void)
426 return i2c_add_driver(&dm355evm_msp_driver);
430 static void __exit dm355evm_msp_exit(
void)