Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remote threaded IRQ, fixed battery info free #9

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions driver/bq2562x_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct bq2562x_init_data {
u32 ext_ilim;
u32 bat_cap;
};

enum bq2562x_state_enum {
BQ2562X_STATE_INIT = 0,
BQ2562X_STATE_IBAT_DIS_ADC1,
Expand Down Expand Up @@ -1301,11 +1302,9 @@ static void bq2562x_manage(struct bq2562x_device *bq, bool timed)
}
}

static irqreturn_t bq2562x_irq_handler_thread(int irq, void *private)
static irqreturn_t bq2562x_irq_handler(int irq, void *private)
{
struct bq2562x_device *bq = private;
BQ2562X_DEBUG(bq->dev, "bq2562x_irq_handler_thread irq:0x%08x pid:%d",
irq, current->pid);
queue_work(bq->wq, &bq->manage_work);
return IRQ_HANDLED;
}
Expand Down Expand Up @@ -1560,7 +1559,7 @@ static int bq2562x_fixup_battery_info(struct bq2562x_device *bq)
static void bq2562x_cleanup_battery_info(void *data)
{
struct bq2562x_device *bq = data;
power_supply_put_battery_info(bq->battery, bq->bat_info);
power_supply_put_battery_info(bq->charger, bq->bat_info);
}

static int bq2562x_hw_init(struct bq2562x_device *bq)
Expand Down Expand Up @@ -1605,17 +1604,17 @@ static int bq2562x_hw_init(struct bq2562x_device *bq)
bq->init_data.ichg_max = bq->bat_info->constant_charge_current_max_ua;
bq->init_data.vreg_max = bq->bat_info->constant_charge_voltage_max_uv;
bq->init_data.bat_cap = bq->bat_info->charge_full_design_uah;
bq->init_data.iterm = bq->bat_info->charge_term_current_ua;
bq->init_data.iprechg = bq->bat_info->precharge_current_ua;

bq->bat_state.curr_percent = 0;
// initialize charge current
bq->state.ichg_curr = bq->init_data.ichg_max;
RET_NZ(bq2562x_set_ichrg_curr, bq, bq->init_data.ichg_max);
RET_NZ(bq2562x_set_prechrg_curr, bq,
bq->bat_info->precharge_current_ua);
RET_NZ(bq2562x_set_chrg_volt, bq,
bq->bat_info->constant_charge_voltage_max_uv);
RET_NZ(bq2562x_set_prechrg_curr, bq, bq->init_data.iprechg);
RET_NZ(bq2562x_set_chrg_volt, bq, bq->init_data.vreg_max);

RET_NZ(bq2562x_set_term_curr, bq, bq->bat_info->charge_term_current_ua);
RET_NZ(bq2562x_set_term_curr, bq, bq->init_data.iterm);

RET_NZ(bq2562x_set_input_volt_lim, bq, bq->init_data.vlim);

Expand Down Expand Up @@ -2019,8 +2018,8 @@ static int bq2562x_probe(struct i2c_client *client,
// last step to setup IRQ, as it can be called as soon as
// this returns, resulting in uninitialized state
if (client->irq) {
RET_FAIL(devm_request_threaded_irq, dev, client->irq, NULL,
bq2562x_irq_handler_thread,
RET_FAIL(devm_request_irq, dev, client->irq,
bq2562x_irq_handler,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
dev_name(&client->dev), bq);
}
Expand Down
2 changes: 1 addition & 1 deletion mrhat-bq25622/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: mrhat-bq25622
Version: 0.5.4
Version: 0.6.0
Maintainer: Effective Range Kft.
Architecture: armhf
Description: Device driver and device tree overlay for the TI BQ25622 charger located on Effective-Range MrHAT v1 family of extension hats
Loading