Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 1 | /* |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 2 | * LEDs driver for Freescale MC13783/MC13892/MC34708 |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2010 Philippe Rétornaz |
| 5 | * |
| 6 | * Based on leds-da903x: |
| 7 | * Copyright (C) 2008 Compulab, Ltd. |
| 8 | * Mike Rapoport <mike@compulab.co.il> |
| 9 | * |
| 10 | * Copyright (C) 2006-2008 Marvell International Ltd. |
| 11 | * Eric Miao <eric.miao@marvell.com> |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License version 2 as |
| 15 | * published by the Free Software Foundation. |
| 16 | */ |
| 17 | |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/kernel.h> |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 20 | #include <linux/platform_device.h> |
| 21 | #include <linux/leds.h> |
Alexander Shiyan | 25c6579 | 2014-01-31 22:37:23 -0800 | [diff] [blame] | 22 | #include <linux/of.h> |
David Jander | f3ca078 | 2011-08-24 15:28:20 +0200 | [diff] [blame] | 23 | #include <linux/mfd/mc13xxx.h> |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 24 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 25 | struct mc13xxx_led_devtype { |
| 26 | int led_min; |
| 27 | int led_max; |
| 28 | int num_regs; |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 29 | u32 ledctrl_base; |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | struct mc13xxx_led { |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 33 | struct led_classdev cdev; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 34 | int id; |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 35 | struct mc13xxx_leds *leds; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 36 | }; |
| 37 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 38 | struct mc13xxx_leds { |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 39 | struct mc13xxx *master; |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 40 | struct mc13xxx_led_devtype *devtype; |
| 41 | int num_leds; |
Alexander Shiyan | 25c6579 | 2014-01-31 22:37:23 -0800 | [diff] [blame] | 42 | struct mc13xxx_led *led; |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 43 | }; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 44 | |
Alexander Shiyan | 677d13f | 2014-01-31 22:36:30 -0800 | [diff] [blame] | 45 | static unsigned int mc13xxx_max_brightness(int id) |
| 46 | { |
| 47 | if (id >= MC13783_LED_MD && id <= MC13783_LED_KP) |
| 48 | return 0x0f; |
| 49 | else if (id >= MC13783_LED_R1 && id <= MC13783_LED_B3) |
| 50 | return 0x1f; |
| 51 | |
| 52 | return 0x3f; |
| 53 | } |
| 54 | |
Andrew Lunn | 4330f2f | 2015-08-20 12:52:08 +0200 | [diff] [blame] | 55 | static int mc13xxx_led_set(struct led_classdev *led_cdev, |
| 56 | enum led_brightness value) |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 57 | { |
Andrew Lunn | 4330f2f | 2015-08-20 12:52:08 +0200 | [diff] [blame] | 58 | struct mc13xxx_led *led = |
| 59 | container_of(led_cdev, struct mc13xxx_led, cdev); |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 60 | struct mc13xxx_leds *leds = led->leds; |
Alexander Shiyan | 677d13f | 2014-01-31 22:36:30 -0800 | [diff] [blame] | 61 | unsigned int reg, bank, off, shift; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 62 | |
| 63 | switch (led->id) { |
| 64 | case MC13783_LED_MD: |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 65 | case MC13783_LED_AD: |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 66 | case MC13783_LED_KP: |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 67 | reg = 2; |
| 68 | shift = 9 + (led->id - MC13783_LED_MD) * 4; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 69 | break; |
| 70 | case MC13783_LED_R1: |
| 71 | case MC13783_LED_G1: |
| 72 | case MC13783_LED_B1: |
| 73 | case MC13783_LED_R2: |
| 74 | case MC13783_LED_G2: |
| 75 | case MC13783_LED_B2: |
| 76 | case MC13783_LED_R3: |
| 77 | case MC13783_LED_G3: |
| 78 | case MC13783_LED_B3: |
| 79 | off = led->id - MC13783_LED_R1; |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 80 | bank = off / 3; |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 81 | reg = 3 + bank; |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 82 | shift = (off - bank * 3) * 5 + 6; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 83 | break; |
Alexander Shiyan | ae6cdb0 | 2013-06-10 09:59:31 -0700 | [diff] [blame] | 84 | case MC13892_LED_MD: |
Alexander Shiyan | ae6cdb0 | 2013-06-10 09:59:31 -0700 | [diff] [blame] | 85 | case MC13892_LED_AD: |
Alexander Shiyan | ae6cdb0 | 2013-06-10 09:59:31 -0700 | [diff] [blame] | 86 | case MC13892_LED_KP: |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 87 | reg = (led->id - MC13892_LED_MD) / 2; |
| 88 | shift = 3 + (led->id - MC13892_LED_MD) * 12; |
Alexander Shiyan | ae6cdb0 | 2013-06-10 09:59:31 -0700 | [diff] [blame] | 89 | break; |
| 90 | case MC13892_LED_R: |
| 91 | case MC13892_LED_G: |
| 92 | case MC13892_LED_B: |
| 93 | off = led->id - MC13892_LED_R; |
| 94 | bank = off / 2; |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 95 | reg = 2 + bank; |
Alexander Shiyan | ae6cdb0 | 2013-06-10 09:59:31 -0700 | [diff] [blame] | 96 | shift = (off - bank * 2) * 12 + 3; |
Alexander Shiyan | ae6cdb0 | 2013-06-10 09:59:31 -0700 | [diff] [blame] | 97 | break; |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 98 | case MC34708_LED_R: |
| 99 | case MC34708_LED_G: |
| 100 | reg = 0; |
| 101 | shift = 3 + (led->id - MC34708_LED_R) * 12; |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 102 | break; |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 103 | default: |
| 104 | BUG(); |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 105 | } |
| 106 | |
Andrew Lunn | 4330f2f | 2015-08-20 12:52:08 +0200 | [diff] [blame] | 107 | return mc13xxx_reg_rmw(leds->master, leds->devtype->ledctrl_base + reg, |
Alexander Shiyan | 677d13f | 2014-01-31 22:36:30 -0800 | [diff] [blame] | 108 | mc13xxx_max_brightness(led->id) << shift, |
Andrew Lunn | 4330f2f | 2015-08-20 12:52:08 +0200 | [diff] [blame] | 109 | value << shift); |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 110 | } |
| 111 | |
Alexander Shiyan | 25c6579 | 2014-01-31 22:37:23 -0800 | [diff] [blame] | 112 | #ifdef CONFIG_OF |
| 113 | static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( |
| 114 | struct platform_device *pdev) |
| 115 | { |
| 116 | struct mc13xxx_leds *leds = platform_get_drvdata(pdev); |
| 117 | struct mc13xxx_leds_platform_data *pdata; |
| 118 | struct device_node *parent, *child; |
| 119 | struct device *dev = &pdev->dev; |
| 120 | int i = 0, ret = -ENODATA; |
| 121 | |
| 122 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); |
| 123 | if (!pdata) |
| 124 | return ERR_PTR(-ENOMEM); |
| 125 | |
Geert Uytterhoeven | 452bc14 | 2015-01-14 05:51:58 -0800 | [diff] [blame] | 126 | parent = of_get_child_by_name(dev->parent->of_node, "leds"); |
Alexander Shiyan | 25c6579 | 2014-01-31 22:37:23 -0800 | [diff] [blame] | 127 | if (!parent) |
| 128 | goto out_node_put; |
| 129 | |
| 130 | ret = of_property_read_u32_array(parent, "led-control", |
| 131 | pdata->led_control, |
| 132 | leds->devtype->num_regs); |
| 133 | if (ret) |
| 134 | goto out_node_put; |
| 135 | |
| 136 | pdata->num_leds = of_get_child_count(parent); |
| 137 | |
| 138 | pdata->led = devm_kzalloc(dev, pdata->num_leds * sizeof(*pdata->led), |
| 139 | GFP_KERNEL); |
| 140 | if (!pdata->led) { |
| 141 | ret = -ENOMEM; |
| 142 | goto out_node_put; |
| 143 | } |
| 144 | |
| 145 | for_each_child_of_node(parent, child) { |
| 146 | const char *str; |
| 147 | u32 tmp; |
| 148 | |
| 149 | if (of_property_read_u32(child, "reg", &tmp)) |
| 150 | continue; |
| 151 | pdata->led[i].id = leds->devtype->led_min + tmp; |
| 152 | |
| 153 | if (!of_property_read_string(child, "label", &str)) |
| 154 | pdata->led[i].name = str; |
| 155 | if (!of_property_read_string(child, "linux,default-trigger", |
| 156 | &str)) |
| 157 | pdata->led[i].default_trigger = str; |
| 158 | |
| 159 | i++; |
| 160 | } |
| 161 | |
| 162 | pdata->num_leds = i; |
| 163 | ret = i > 0 ? 0 : -ENODATA; |
| 164 | |
| 165 | out_node_put: |
| 166 | of_node_put(parent); |
| 167 | |
| 168 | return ret ? ERR_PTR(ret) : pdata; |
| 169 | } |
| 170 | #else |
| 171 | static inline struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( |
| 172 | struct platform_device *pdev) |
| 173 | { |
| 174 | return ERR_PTR(-ENOSYS); |
| 175 | } |
| 176 | #endif |
| 177 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 178 | static int __init mc13xxx_led_probe(struct platform_device *pdev) |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 179 | { |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 180 | struct device *dev = &pdev->dev; |
| 181 | struct mc13xxx_leds_platform_data *pdata = dev_get_platdata(dev); |
| 182 | struct mc13xxx *mcdev = dev_get_drvdata(dev->parent); |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 183 | struct mc13xxx_led_devtype *devtype = |
| 184 | (struct mc13xxx_led_devtype *)pdev->id_entry->driver_data; |
| 185 | struct mc13xxx_leds *leds; |
Alexander Shiyan | 25c6579 | 2014-01-31 22:37:23 -0800 | [diff] [blame] | 186 | int i, id, ret = -ENODATA; |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 187 | u32 init_led = 0; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 188 | |
Alexander Shiyan | 25c6579 | 2014-01-31 22:37:23 -0800 | [diff] [blame] | 189 | leds = devm_kzalloc(dev, sizeof(*leds), GFP_KERNEL); |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 190 | if (!leds) |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 191 | return -ENOMEM; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 192 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 193 | leds->devtype = devtype; |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 194 | leds->master = mcdev; |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 195 | platform_set_drvdata(pdev, leds); |
| 196 | |
Alexander Shiyan | 25c6579 | 2014-01-31 22:37:23 -0800 | [diff] [blame] | 197 | if (dev->parent->of_node) { |
| 198 | pdata = mc13xxx_led_probe_dt(pdev); |
| 199 | if (IS_ERR(pdata)) |
| 200 | return PTR_ERR(pdata); |
| 201 | } else if (!pdata) |
| 202 | return -ENODATA; |
| 203 | |
| 204 | leds->num_leds = pdata->num_leds; |
| 205 | |
| 206 | if ((leds->num_leds < 1) || |
| 207 | (leds->num_leds > (devtype->led_max - devtype->led_min + 1))) { |
| 208 | dev_err(dev, "Invalid LED count %d\n", leds->num_leds); |
| 209 | return -EINVAL; |
| 210 | } |
| 211 | |
| 212 | leds->led = devm_kzalloc(dev, leds->num_leds * sizeof(*leds->led), |
| 213 | GFP_KERNEL); |
| 214 | if (!leds->led) |
| 215 | return -ENOMEM; |
| 216 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 217 | for (i = 0; i < devtype->num_regs; i++) { |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 218 | ret = mc13xxx_reg_write(mcdev, leds->devtype->ledctrl_base + i, |
| 219 | pdata->led_control[i]); |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 220 | if (ret) |
Alexander Shiyan | 3df22c0 | 2013-12-06 22:22:19 -0800 | [diff] [blame] | 221 | return ret; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 222 | } |
| 223 | |
Alexander Shiyan | 25c6579 | 2014-01-31 22:37:23 -0800 | [diff] [blame] | 224 | for (i = 0; i < leds->num_leds; i++) { |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 225 | const char *name, *trig; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 226 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 227 | ret = -EINVAL; |
| 228 | |
| 229 | id = pdata->led[i].id; |
| 230 | name = pdata->led[i].name; |
| 231 | trig = pdata->led[i].default_trigger; |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 232 | |
| 233 | if ((id > devtype->led_max) || (id < devtype->led_min)) { |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 234 | dev_err(dev, "Invalid ID %i\n", id); |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 235 | break; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 236 | } |
| 237 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 238 | if (init_led & (1 << id)) { |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 239 | dev_warn(dev, "LED %i already initialized\n", id); |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 240 | break; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 241 | } |
| 242 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 243 | init_led |= 1 << id; |
| 244 | leds->led[i].id = id; |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 245 | leds->led[i].leds = leds; |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 246 | leds->led[i].cdev.name = name; |
| 247 | leds->led[i].cdev.default_trigger = trig; |
Alexander Shiyan | 02e9e11 | 2014-01-31 22:36:29 -0800 | [diff] [blame] | 248 | leds->led[i].cdev.flags = LED_CORE_SUSPENDRESUME; |
Andrew Lunn | 4330f2f | 2015-08-20 12:52:08 +0200 | [diff] [blame] | 249 | leds->led[i].cdev.brightness_set_blocking = mc13xxx_led_set; |
Alexander Shiyan | 677d13f | 2014-01-31 22:36:30 -0800 | [diff] [blame] | 250 | leds->led[i].cdev.max_brightness = mc13xxx_max_brightness(id); |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 251 | |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 252 | ret = led_classdev_register(dev->parent, &leds->led[i].cdev); |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 253 | if (ret) { |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 254 | dev_err(dev, "Failed to register LED %i\n", id); |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 255 | break; |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 259 | if (ret) |
Andrew Lunn | 4330f2f | 2015-08-20 12:52:08 +0200 | [diff] [blame] | 260 | while (--i >= 0) |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 261 | led_classdev_unregister(&leds->led[i].cdev); |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 262 | |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 263 | return ret; |
| 264 | } |
| 265 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 266 | static int mc13xxx_led_remove(struct platform_device *pdev) |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 267 | { |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 268 | struct mc13xxx_leds *leds = platform_get_drvdata(pdev); |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 269 | int i; |
| 270 | |
Andrew Lunn | 4330f2f | 2015-08-20 12:52:08 +0200 | [diff] [blame] | 271 | for (i = 0; i < leds->num_leds; i++) |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 272 | led_classdev_unregister(&leds->led[i].cdev); |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 273 | |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 274 | return 0; |
| 275 | } |
| 276 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 277 | static const struct mc13xxx_led_devtype mc13783_led_devtype = { |
| 278 | .led_min = MC13783_LED_MD, |
| 279 | .led_max = MC13783_LED_B3, |
| 280 | .num_regs = 6, |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 281 | .ledctrl_base = 51, |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 282 | }; |
| 283 | |
Alexander Shiyan | ae6cdb0 | 2013-06-10 09:59:31 -0700 | [diff] [blame] | 284 | static const struct mc13xxx_led_devtype mc13892_led_devtype = { |
| 285 | .led_min = MC13892_LED_MD, |
| 286 | .led_max = MC13892_LED_B, |
| 287 | .num_regs = 4, |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 288 | .ledctrl_base = 51, |
| 289 | }; |
| 290 | |
| 291 | static const struct mc13xxx_led_devtype mc34708_led_devtype = { |
| 292 | .led_min = MC34708_LED_R, |
| 293 | .led_max = MC34708_LED_G, |
| 294 | .num_regs = 1, |
| 295 | .ledctrl_base = 54, |
Alexander Shiyan | ae6cdb0 | 2013-06-10 09:59:31 -0700 | [diff] [blame] | 296 | }; |
| 297 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 298 | static const struct platform_device_id mc13xxx_led_id_table[] = { |
| 299 | { "mc13783-led", (kernel_ulong_t)&mc13783_led_devtype, }, |
Alexander Shiyan | ae6cdb0 | 2013-06-10 09:59:31 -0700 | [diff] [blame] | 300 | { "mc13892-led", (kernel_ulong_t)&mc13892_led_devtype, }, |
Alexander Shiyan | a59ce65 | 2014-01-31 22:36:28 -0800 | [diff] [blame] | 301 | { "mc34708-led", (kernel_ulong_t)&mc34708_led_devtype, }, |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 302 | { } |
| 303 | }; |
| 304 | MODULE_DEVICE_TABLE(platform, mc13xxx_led_id_table); |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 305 | |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 306 | static struct platform_driver mc13xxx_led_driver = { |
| 307 | .driver = { |
| 308 | .name = "mc13xxx-led", |
Alexander Shiyan | 9d263813 | 2013-06-10 09:59:30 -0700 | [diff] [blame] | 309 | }, |
| 310 | .remove = mc13xxx_led_remove, |
| 311 | .id_table = mc13xxx_led_id_table, |
| 312 | }; |
| 313 | module_platform_driver_probe(mc13xxx_led_driver, mc13xxx_led_probe); |
| 314 | |
| 315 | MODULE_DESCRIPTION("LEDs driver for Freescale MC13XXX PMIC"); |
Philippe Rétornaz | 7fdcef8 | 2010-05-19 09:24:31 +0200 | [diff] [blame] | 316 | MODULE_AUTHOR("Philippe Retornaz <philippe.retornaz@epfl.ch>"); |
| 317 | MODULE_LICENSE("GPL"); |