mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-22 23:04:43 +00:00
power: Add an axp20x-usb-power driver
This adds a driver for the usb power_supply bits of the axp20x PMICs. I initially started writing my own driver, before coming aware of Bruno Prémont's excellent earlier RFC with a driver for this. My driver was lacking CURRENT_MAX and VOLTAGE_MIN support Bruno's drvier has, so I've copied the code for those from his driver. Note that the AC-power-supply and battery charger bits will need separate drivers. Each one needs its own devictree child-node so that other devicetree nodes can reference the right power-supply, and thus each one will get its own mfd-cell / platform_device and platform-driver. Cc: Bruno Prémont <bonbons@linux-vserver.org> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
This commit is contained in:
parent
264905209a
commit
69fb4dcada
4 changed files with 280 additions and 0 deletions
|
@ -11,6 +11,8 @@
|
|||
#ifndef __LINUX_MFD_AXP20X_H
|
||||
#define __LINUX_MFD_AXP20X_H
|
||||
|
||||
#include <linux/regmap.h>
|
||||
|
||||
enum {
|
||||
AXP152_ID = 0,
|
||||
AXP202_ID,
|
||||
|
@ -438,4 +440,26 @@ struct axp288_extcon_pdata {
|
|||
struct gpio_desc *gpio_mux_cntl;
|
||||
};
|
||||
|
||||
/* generic helper function for reading 9-16 bit wide regs */
|
||||
static inline int axp20x_read_variable_width(struct regmap *regmap,
|
||||
unsigned int reg, unsigned int width)
|
||||
{
|
||||
unsigned int reg_val, result;
|
||||
int err;
|
||||
|
||||
err = regmap_read(regmap, reg, ®_val);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
result = reg_val << (width - 8);
|
||||
|
||||
err = regmap_read(regmap, reg + 1, ®_val);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
result |= reg_val;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif /* __LINUX_MFD_AXP20X_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue