25 #include <linux/module.h>
26 #include <linux/slab.h>
46 static int max8903_get_property(
struct power_supply *psy,
56 if (data->
pdata.chg) {
81 static irqreturn_t max8903_dcin(
int irq,
void *_data)
90 if (ta_in == data->
ta_in)
104 dev_dbg(data->
dev,
"TA(DC-IN) Charger %s.\n", ta_in ?
105 "Connected" :
"Disconnected");
107 old_type = data->
psy.type;
116 if (old_type != data->
psy.type)
122 static irqreturn_t max8903_usbin(
int irq,
void *_data)
131 if (usb_in == data->
usb_in)
141 (data->
ta_in ? 0 : 1));
143 dev_dbg(data->
dev,
"USB Charger %s.\n", usb_in ?
144 "Connected" :
"Disconnected");
146 old_type = data->
psy.type;
155 if (old_type != data->
psy.type)
161 static irqreturn_t max8903_fault(
int irq,
void *_data)
169 if (fault == data->
fault)
175 dev_err(data->
dev,
"Charger suffers a fault and stops.\n");
177 dev_err(data->
dev,
"Charger recovered from a fault.\n");
194 dev_err(dev,
"Cannot allocate memory.\n");
199 platform_set_drvdata(pdev, data);
202 dev_err(dev,
"No valid power sources.\n");
208 if (pdata->
dok && gpio_is_valid(pdata->
dok) &&
209 pdata->
dcm && gpio_is_valid(pdata->
dcm)) {
216 dev_err(dev,
"When DC is wired, DOK and DCM should"
217 " be wired as well.\n");
223 if (gpio_is_valid(pdata->
dcm))
226 dev_err(dev,
"Invalid pin: dcm.\n");
234 if (pdata->
uok && gpio_is_valid(pdata->
uok)) {
238 dev_err(dev,
"When USB is wired, UOK should be wired."
246 if (gpio_is_valid(pdata->
cen)) {
249 dev_err(dev,
"Invalid pin: cen.\n");
256 if (!gpio_is_valid(pdata->
chg)) {
257 dev_err(dev,
"Invalid pin: chg.\n");
264 if (!gpio_is_valid(pdata->
flt)) {
265 dev_err(dev,
"Invalid pin: flt.\n");
272 if (!gpio_is_valid(pdata->
usus)) {
273 dev_err(dev,
"Invalid pin: usus.\n");
283 data->
psy.name =
"max8903_charger";
287 data->
psy.get_property = max8903_get_property;
288 data->
psy.properties = max8903_charger_props;
289 data->
psy.num_properties =
ARRAY_SIZE(max8903_charger_props);
293 dev_err(dev,
"failed: power supply register.\n");
301 "MAX8903 DC IN", data);
303 dev_err(dev,
"Cannot request irq %d for DC (%d)\n",
313 "MAX8903 USB IN", data);
315 dev_err(dev,
"Cannot request irq %d for USB (%d)\n",
325 "MAX8903 Fault", data);
327 dev_err(dev,
"Cannot request irq %d for Fault (%d)\n",
369 .probe = max8903_probe,
372 .name =
"max8903-charger",