aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2013-10-20 23:58:24 -0400
committerOlof Johansson <olof@lixom.net>2013-11-25 15:51:02 -0500
commitec199dd57ef71858b53828283ac495ed82164933 (patch)
treed5ee893dec62a6de613454610461ab27a6f79251 /drivers/platform
parent9742e127cd0dd5783f8c11c62d07886003114499 (diff)
platform/chrome: chromeos_laptop - Restructure device associations
The previous code had a single DMI matching entry for each device on a board. Instead provide a single DMI entry for each board which references a structure about each board that lists the associated peripherals. This allows for a lower number of DMI matching sequences as well making it easier to add new boards. Signed-off-by: Aaron Durbin <adurbin@chromium.org> Signed-off-by: Benson Leung <bleung@chromium.org> Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/chrome/chromeos_laptop.c197
1 files changed, 126 insertions, 71 deletions
diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c
index 3e5b4497a1d0..5c69cfd97ff0 100644
--- a/drivers/platform/chrome/chromeos_laptop.c
+++ b/drivers/platform/chrome/chromeos_laptop.c
@@ -53,6 +53,17 @@ enum i2c_adapter_type {
53 I2C_ADAPTER_PANEL, 53 I2C_ADAPTER_PANEL,
54}; 54};
55 55
56struct i2c_peripheral {
57 void (*add)(enum i2c_adapter_type type);
58 enum i2c_adapter_type type;
59};
60
61#define MAX_I2C_PERIPHERALS 3
62
63struct chromeos_laptop {
64 struct i2c_peripheral i2c_peripherals[MAX_I2C_PERIPHERALS];
65};
66
56static struct i2c_board_info __initdata cyapa_device = { 67static struct i2c_board_info __initdata cyapa_device = {
57 I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR), 68 I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR),
58 .flags = I2C_CLIENT_WAKE, 69 .flags = I2C_CLIENT_WAKE,
@@ -233,149 +244,193 @@ static __init struct i2c_client *add_i2c_device(const char *name,
233 addr_list); 244 addr_list);
234} 245}
235 246
236 247static int __init setup_cyapa_tp(enum i2c_adapter_type type)
237static struct i2c_client __init *add_smbus_device(const char *name,
238 struct i2c_board_info *info)
239{
240 return add_i2c_device(name, I2C_ADAPTER_SMBUS, info);
241}
242
243static int __init setup_cyapa_smbus_tp(const struct dmi_system_id *id)
244{ 248{
245 /* add cyapa touchpad on smbus */ 249 /* add cyapa touchpad */
246 tp = add_smbus_device("trackpad", &cyapa_device); 250 tp = add_i2c_device("trackpad", type, &cyapa_device);
247 return 0; 251 return 0;
248} 252}
249 253
250static int __init setup_atmel_224s_tp(const struct dmi_system_id *id) 254static int __init setup_atmel_224s_tp(enum i2c_adapter_type type)
251{ 255{
252 const unsigned short addr_list[] = { ATMEL_TP_I2C_BL_ADDR, 256 const unsigned short addr_list[] = { ATMEL_TP_I2C_BL_ADDR,
253 ATMEL_TP_I2C_ADDR, 257 ATMEL_TP_I2C_ADDR,
254 I2C_CLIENT_END }; 258 I2C_CLIENT_END };
255 259
256 /* add atmel mxt touchpad on VGA DDC GMBus */ 260 /* add atmel mxt touchpad */
257 tp = add_probed_i2c_device("trackpad", I2C_ADAPTER_VGADDC, 261 tp = add_probed_i2c_device("trackpad", type,
258 &atmel_224s_tp_device, addr_list); 262 &atmel_224s_tp_device, addr_list);
259 return 0; 263 return 0;
260} 264}
261 265
262static int __init setup_atmel_1664s_ts(const struct dmi_system_id *id) 266static int __init setup_atmel_1664s_ts(enum i2c_adapter_type type)
263{ 267{
264 const unsigned short addr_list[] = { ATMEL_TS_I2C_BL_ADDR, 268 const unsigned short addr_list[] = { ATMEL_TS_I2C_BL_ADDR,
265 ATMEL_TS_I2C_ADDR, 269 ATMEL_TS_I2C_ADDR,
266 I2C_CLIENT_END }; 270 I2C_CLIENT_END };
267 271
268 /* add atmel mxt touch device on PANEL GMBus */ 272 /* add atmel mxt touch device */
269 ts = add_probed_i2c_device("touchscreen", I2C_ADAPTER_PANEL, 273 ts = add_probed_i2c_device("touchscreen", type,
270 &atmel_1664s_device, addr_list); 274 &atmel_1664s_device, addr_list);
271 return 0; 275 return 0;
272} 276}
273 277
274 278static int __init setup_isl29018_als(enum i2c_adapter_type type)
275static int __init setup_isl29018_als(const struct dmi_system_id *id)
276{ 279{
277 /* add isl29018 light sensor */ 280 /* add isl29018 light sensor */
278 als = add_smbus_device("lightsensor", &isl_als_device); 281 als = add_i2c_device("lightsensor", type, &isl_als_device);
279 return 0; 282 return 0;
280} 283}
281 284
282static int __init setup_isl29023_als(const struct dmi_system_id *id) 285static int __init setup_tsl2583_als(enum i2c_adapter_type type)
283{ 286{
284 /* add isl29023 light sensor on Panel GMBus */ 287 /* add tsl2583 light sensor */
285 als = add_i2c_device("lightsensor", I2C_ADAPTER_PANEL, 288 als = add_i2c_device(NULL, type, &tsl2583_als_device);
286 &isl_als_device);
287 return 0; 289 return 0;
288} 290}
289 291
290static int __init setup_tsl2583_als(const struct dmi_system_id *id) 292static int __init setup_tsl2563_als(enum i2c_adapter_type type)
291{ 293{
292 /* add tsl2583 light sensor on smbus */ 294 /* add tsl2563 light sensor */
293 als = add_smbus_device(NULL, &tsl2583_als_device); 295 als = add_i2c_device(NULL, type, &tsl2563_als_device);
294 return 0; 296 return 0;
295} 297}
296 298
297static int __init setup_tsl2563_als(const struct dmi_system_id *id) 299static int __init
300chromeos_laptop_add_peripherals(const struct dmi_system_id *id)
298{ 301{
299 /* add tsl2563 light sensor on smbus */ 302 int i;
300 als = add_smbus_device(NULL, &tsl2563_als_device); 303 struct chromeos_laptop *cros_laptop = (void *)id->driver_data;
301 return 0; 304
305 pr_debug("Adding peripherals for %s.\n", id->ident);
306
307 for (i = 0; i < MAX_I2C_PERIPHERALS; i++) {
308 struct i2c_peripheral *i2c_dev;
309
310 i2c_dev = &cros_laptop->i2c_peripherals[i];
311
312 /* No more peripherals. */
313 if (i2c_dev->add == NULL)
314 break;
315
316 /* Add the device. */
317 i2c_dev->add(i2c_dev->type);
318 }
319
320 /* Indicate to dmi_scan that processing is done. */
321 return 1;
302} 322}
303 323
324static struct chromeos_laptop samsung_series_5_550 __initdata = {
325 .i2c_peripherals = {
326 /* Touchpad. */
327 { .add = setup_cyapa_tp, I2C_ADAPTER_SMBUS },
328 /* Light Sensor. */
329 { .add = setup_isl29018_als, I2C_ADAPTER_SMBUS },
330 },
331};
332
333static struct chromeos_laptop samsung_series_5 __initdata = {
334 .i2c_peripherals = {
335 /* Light Sensor. */
336 { .add = setup_tsl2583_als, I2C_ADAPTER_SMBUS },
337 },
338};
339
340static struct chromeos_laptop chromebook_pixel __initdata = {
341 .i2c_peripherals = {
342 /* Touch Screen. */
343 { .add = setup_atmel_1664s_ts, I2C_ADAPTER_PANEL },
344 /* Touchpad. */
345 { .add = setup_atmel_224s_tp, I2C_ADAPTER_VGADDC },
346 /* Light Sensor. */
347 { .add = setup_isl29018_als, I2C_ADAPTER_PANEL },
348 },
349};
350
351static struct chromeos_laptop acer_c7_chromebook __initdata = {
352 .i2c_peripherals = {
353 /* Touchpad. */
354 { .add = setup_cyapa_tp, I2C_ADAPTER_SMBUS },
355 },
356};
357
358static struct chromeos_laptop acer_ac700 __initdata = {
359 .i2c_peripherals = {
360 /* Light Sensor. */
361 { .add = setup_tsl2563_als, I2C_ADAPTER_SMBUS },
362 },
363};
364
365static struct chromeos_laptop hp_pavilion_14_chromebook __initdata = {
366 .i2c_peripherals = {
367 /* Touchpad. */
368 { .add = setup_cyapa_tp, I2C_ADAPTER_SMBUS },
369 },
370};
371
372static struct chromeos_laptop cr48 __initdata = {
373 .i2c_peripherals = {
374 /* Light Sensor. */
375 { .add = setup_tsl2563_als, I2C_ADAPTER_SMBUS },
376 },
377};
378
379#define _CBDD(board_) \
380 .callback = &chromeos_laptop_add_peripherals, \
381 .driver_data = (void *)&board_
382
304static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = { 383static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
305 { 384 {
306 .ident = "Samsung Series 5 550 - Touchpad", 385 .ident = "Samsung Series 5 550",
307 .matches = { 386 .matches = {
308 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG"), 387 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG"),
309 DMI_MATCH(DMI_PRODUCT_NAME, "Lumpy"), 388 DMI_MATCH(DMI_PRODUCT_NAME, "Lumpy"),
310 }, 389 },
311 .callback = setup_cyapa_smbus_tp, 390 _CBDD(samsung_series_5_550),
312 },
313 {
314 .ident = "Chromebook Pixel - Touchscreen",
315 .matches = {
316 DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),
317 DMI_MATCH(DMI_PRODUCT_NAME, "Link"),
318 },
319 .callback = setup_atmel_1664s_ts,
320 },
321 {
322 .ident = "Chromebook Pixel - Touchpad",
323 .matches = {
324 DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),
325 DMI_MATCH(DMI_PRODUCT_NAME, "Link"),
326 },
327 .callback = setup_atmel_224s_tp,
328 }, 391 },
329 { 392 {
330 .ident = "Samsung Series 5 550 - Light Sensor", 393 .ident = "Samsung Series 5",
331 .matches = { 394 .matches = {
332 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG"), 395 DMI_MATCH(DMI_PRODUCT_NAME, "Alex"),
333 DMI_MATCH(DMI_PRODUCT_NAME, "Lumpy"),
334 }, 396 },
335 .callback = setup_isl29018_als, 397 _CBDD(samsung_series_5),
336 }, 398 },
337 { 399 {
338 .ident = "Chromebook Pixel - Light Sensor", 400 .ident = "Chromebook Pixel",
339 .matches = { 401 .matches = {
340 DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), 402 DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),
341 DMI_MATCH(DMI_PRODUCT_NAME, "Link"), 403 DMI_MATCH(DMI_PRODUCT_NAME, "Link"),
342 }, 404 },
343 .callback = setup_isl29023_als, 405 _CBDD(chromebook_pixel),
344 }, 406 },
345 { 407 {
346 .ident = "Acer C7 Chromebook - Touchpad", 408 .ident = "Acer C7 Chromebook",
347 .matches = { 409 .matches = {
348 DMI_MATCH(DMI_PRODUCT_NAME, "Parrot"), 410 DMI_MATCH(DMI_PRODUCT_NAME, "Parrot"),
349 }, 411 },
350 .callback = setup_cyapa_smbus_tp, 412 _CBDD(acer_c7_chromebook),
351 }, 413 },
352 { 414 {
353 .ident = "HP Pavilion 14 Chromebook - Touchpad", 415 .ident = "Acer AC700",
354 .matches = { 416 .matches = {
355 DMI_MATCH(DMI_PRODUCT_NAME, "Butterfly"), 417 DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"),
356 }, 418 },
357 .callback = setup_cyapa_smbus_tp, 419 _CBDD(acer_ac700),
358 }, 420 },
359 { 421 {
360 .ident = "Samsung Series 5 - Light Sensor", 422 .ident = "HP Pavilion 14 Chromebook",
361 .matches = { 423 .matches = {
362 DMI_MATCH(DMI_PRODUCT_NAME, "Alex"), 424 DMI_MATCH(DMI_PRODUCT_NAME, "Butterfly"),
363 }, 425 },
364 .callback = setup_tsl2583_als, 426 _CBDD(hp_pavilion_14_chromebook),
365 }, 427 },
366 { 428 {
367 .ident = "Cr-48 - Light Sensor", 429 .ident = "Cr-48",
368 .matches = { 430 .matches = {
369 DMI_MATCH(DMI_PRODUCT_NAME, "Mario"), 431 DMI_MATCH(DMI_PRODUCT_NAME, "Mario"),
370 }, 432 },
371 .callback = setup_tsl2563_als, 433 _CBDD(cr48),
372 },
373 {
374 .ident = "Acer AC700 - Light Sensor",
375 .matches = {
376 DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"),
377 },
378 .callback = setup_tsl2563_als,
379 }, 434 },
380 { } 435 { }
381}; 436};