Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: pca963x: Add bindings to invert polarity

Add a new DT property, nxp,inverted-out, to invert the polarity
of the output.

Tested on PCA9634.

Signed-off-by: Anders Darander <anders@chargestorm.se>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>

authored by

Anders Darander and committed by
Jacek Anaszewski
bb29b9cc 2ea659a9

+22 -2
+1
Documentation/devicetree/bindings/leds/pca963x.txt
··· 10 10 - nxp,period-scale : In some configurations, the chip blinks faster than expected. 11 11 This parameter provides a scaling ratio (fixed point, decimal divided 12 12 by 1000) to compensate, e.g. 1300=1.3x and 750=0.75x. 13 + - nxp,inverted-out: invert the polarity of the generated PWM 13 14 14 15 Each led is represented as a sub-node of the nxp,pca963x device. 15 16
+15 -2
drivers/leds/leds-pca963x.c
··· 342 342 if (of_property_read_u32(np, "nxp,period-scale", &chip->scaling)) 343 343 chip->scaling = 1000; 344 344 345 + /* default to non-inverted output, unless inverted is specified */ 346 + if (of_property_read_bool(np, "nxp,inverted-out")) 347 + pdata->dir = PCA963X_INVERTED; 348 + else 349 + pdata->dir = PCA963X_NORMAL; 350 + 345 351 return pdata; 346 352 } 347 353 ··· 458 452 i2c_smbus_write_byte_data(client, PCA963X_MODE1, BIT(4)); 459 453 460 454 if (pdata) { 455 + u8 mode2 = i2c_smbus_read_byte_data(pca963x->chip->client, 456 + PCA963X_MODE2); 461 457 /* Configure output: open-drain or totem pole (push-pull) */ 462 458 if (pdata->outdrv == PCA963X_OPEN_DRAIN) 463 - i2c_smbus_write_byte_data(client, PCA963X_MODE2, 0x01); 459 + mode2 |= 0x01; 464 460 else 465 - i2c_smbus_write_byte_data(client, PCA963X_MODE2, 0x05); 461 + mode2 |= 0x05; 462 + /* Configure direction: normal or inverted */ 463 + if (pdata->dir == PCA963X_INVERTED) 464 + mode2 |= 0x10; 465 + i2c_smbus_write_byte_data(pca963x->chip->client, PCA963X_MODE2, 466 + mode2); 466 467 } 467 468 468 469 return 0;
+6
include/linux/platform_data/leds-pca963x.h
··· 33 33 PCA963X_HW_BLINK, 34 34 }; 35 35 36 + enum pca963x_direction { 37 + PCA963X_NORMAL, 38 + PCA963X_INVERTED, 39 + }; 40 + 36 41 struct pca963x_platform_data { 37 42 struct led_platform_data leds; 38 43 enum pca963x_outdrv outdrv; 39 44 enum pca963x_blink_type blink_type; 45 + enum pca963x_direction dir; 40 46 }; 41 47 42 48 #endif /* __LINUX_PCA963X_H*/