diff options
| author | Abhijeet Dharmapurikar <adharmap@codeaurora.org> | 2016-01-22 15:30:57 -0800 |
|---|---|---|
| committer | Rohit Vaswani <rvaswani@codeaurora.org> | 2016-03-01 12:22:33 -0800 |
| commit | 0c98f90e2e5d7abd362645ffc07b106731609969 (patch) | |
| tree | 556e2e5c1524f71df3d1d97d7bdb8d19a7c6bea2 /drivers/bif | |
| parent | 065fd87ad33b0b00dcbce1ce8880590492aec658 (diff) | |
spmi_devices: change to platform_devices
Change to using upstream spmi bus architecture. All the spmi devices,
marked by spmi-dev-container, become platform devices.
spmi-slave-container devices become spmi_devices each representing
a slave. The read/write functions use regmap api's instead of calls to
spmi_ext_register_read/write() implemented by the spmi bus. This
regmap is instantiated per slave.
The spmi bus helper functions like spmi_get_irq get changed to their
platform bus equivalents.
Change Kconfig files include
* Remove dependence on OF_SPMI, MSM_QPNP_INT
* There were few places where an earlier commit
dcc2aedc80746acee589e4b47d3e6adf5d3ec253
missed adding dependence on SPMI along with MSM_SPMI.
Fix them.
* Add depends on ARCH_MSM. ARCH_MSM is used for internal builds.
Change the nodes in DTSI files to confirm to the modified drivers.
Update their binding docs to drop spmi-dev-container and
spmi-slave-container;
Finally update defconfig to use upstream SPMI.
Change-Id: Ic85bff27c09c84b152cb38acbc3cadd05c0ec57a
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Diffstat (limited to 'drivers/bif')
| -rw-r--r-- | drivers/bif/Kconfig | 3 | ||||
| -rw-r--r-- | drivers/bif/qpnp-bsi.c | 247 |
2 files changed, 152 insertions, 98 deletions
diff --git a/drivers/bif/Kconfig b/drivers/bif/Kconfig index 917920bb9151..1a79ce8fbb08 100644 --- a/drivers/bif/Kconfig +++ b/drivers/bif/Kconfig @@ -13,8 +13,7 @@ menuconfig BIF if BIF config BIF_QPNP - depends on SPMI || MSM_SPMI - depends on OF_SPMI + depends on SPMI tristate "Qualcomm QPNP BIF support" help This driver supports the QPNP BSI peripheral found inside of Qualcomm diff --git a/drivers/bif/qpnp-bsi.c b/drivers/bif/qpnp-bsi.c index c378a40a411d..d61eb39dc5bf 100644 --- a/drivers/bif/qpnp-bsi.c +++ b/drivers/bif/qpnp-bsi.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -17,12 +17,14 @@ #include <linux/device.h> #include <linux/interrupt.h> #include <linux/kernel.h> +#include <linux/regmap.h> #include <linux/module.h> #include <linux/mutex.h> #include <linux/of.h> #include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/spmi.h> +#include <linux/platform_device.h> #include <linux/workqueue.h> #include <linux/bif/driver.h> #include <linux/qpnp/qpnp-adc.h> @@ -41,7 +43,8 @@ enum qpnp_bsi_com_mode { struct qpnp_bsi_chip { struct bif_ctrl_desc bdesc; - struct spmi_device *spmi_dev; + struct platform_device *pdev; + struct regmap *regmap; struct bif_ctrl_dev *bdev; struct work_struct slave_irq_work; u16 base_addr; @@ -202,11 +205,13 @@ static inline int qpnp_bsi_read(struct qpnp_bsi_chip *chip, u16 addr, u8 *buf, { int rc; - rc = spmi_ext_register_readl(chip->spmi_dev->ctrl, - chip->spmi_dev->sid, chip->base_addr + addr, buf, len); + rc = regmap_bulk_read(chip->regmap, chip->base_addr + addr, buf, len); if (rc) - dev_err(&chip->spmi_dev->dev, "%s: spmi_ext_register_readl() failed. sid=%d, addr=%04X, len=%d, rc=%d\n", - __func__, chip->spmi_dev->sid, chip->base_addr + addr, + dev_err(&chip->pdev->dev, + "%s: regmap_bulk_readl failed. sid=%d, addr=%04X, len=%d, rc=%d\n", + __func__, + to_spmi_device(chip->pdev->dev.parent)->usid, + chip->base_addr + addr, len, rc); return rc; @@ -217,12 +222,14 @@ static inline int qpnp_bsi_write(struct qpnp_bsi_chip *chip, u16 addr, u8 *buf, { int rc; - rc = spmi_ext_register_writel(chip->spmi_dev->ctrl, - chip->spmi_dev->sid, chip->base_addr + addr, buf, len); + rc = regmap_bulk_write(chip->regmap, chip->base_addr + addr, buf, len); if (rc) - dev_err(&chip->spmi_dev->dev, "%s: spmi_ext_register_writel() failed. sid=%d, addr=%04X, len=%d, rc=%d\n", - __func__, chip->spmi_dev->sid, chip->base_addr + addr, + dev_err(&chip->pdev->dev, + "%s: regmap_bulk_write failed. sid=%d, addr=%04X, len=%d, rc=%d\n", + __func__, + to_spmi_device(chip->pdev->dev.parent)->usid, + chip->base_addr + addr, len, rc); return rc; @@ -278,14 +285,15 @@ static int qpnp_bsi_rx_tx_config(struct qpnp_bsi_chip *chip, buf[1] = QPNP_BSI_TX_DISABLE | QPNP_BSI_RX_DISABLE; break; default: - dev_err(&chip->spmi_dev->dev, "%s: invalid state=%d\n", + dev_err(&chip->pdev->dev, "%s: invalid state=%d\n", __func__, state); return -EINVAL; } rc = qpnp_bsi_write(chip, QPNP_BSI_REG_MODE, buf, 2); if (rc) - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_write() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_write() failed, rc=%d\n", __func__, rc); return rc; @@ -403,7 +411,8 @@ static int qpnp_bsi_clear_bsi_error(struct qpnp_bsi_chip *chip) rc = qpnp_bsi_read(chip, QPNP_BSI_REG_BSI_ERROR, ®, 1); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_read() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_read() failed, rc=%d\n", __func__, rc); return rc; } @@ -422,7 +431,8 @@ static int qpnp_bsi_clear_bsi_error(struct qpnp_bsi_chip *chip) reg = QPNP_BSI_BSI_ERROR_CLEAR; rc = qpnp_bsi_write(chip, QPNP_BSI_REG_CLEAR_ERROR, ®, 1); if (rc) - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_write() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_write() failed, rc=%d\n", __func__, rc); } @@ -436,7 +446,8 @@ static int qpnp_bsi_get_bsi_error(struct qpnp_bsi_chip *chip) rc = qpnp_bsi_read(chip, QPNP_BSI_REG_BSI_ERROR, ®, 1); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_read() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_read() failed, rc=%d\n", __func__, rc); return rc; } @@ -451,7 +462,8 @@ static int qpnp_bsi_wait_for_tx(struct qpnp_bsi_chip *chip, int timeout) /* Wait for TX or ERR IRQ. */ while (timeout > 0) { if (qpnp_bsi_check_irq(chip, QPNP_BSI_IRQ_ERR)) { - dev_err(&chip->spmi_dev->dev, "%s: transaction error occurred, BSI error=%d\n", + dev_err(&chip->pdev->dev, + "%s: transaction error occurred, BSI error=%d\n", __func__, qpnp_bsi_get_bsi_error(chip)); return -EIO; } @@ -465,7 +477,8 @@ static int qpnp_bsi_wait_for_tx(struct qpnp_bsi_chip *chip, int timeout) if (timeout == 0) { rc = -ETIMEDOUT; - dev_err(&chip->spmi_dev->dev, "%s: transaction timed out, no interrupts received, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: transaction timed out, no interrupts received, rc=%d\n", __func__, rc); return rc; } @@ -491,7 +504,8 @@ static int qpnp_bsi_issue_transaction(struct qpnp_bsi_chip *chip, /* Write the TX_DATA bytes and initiate the transaction. */ rc = qpnp_bsi_write(chip, QPNP_BSI_REG_TX_DATA_LOW, buf, 4); if (rc) - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_write() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_write() failed, rc=%d\n", __func__, rc); return rc; } @@ -520,7 +534,8 @@ static int qpnp_bsi_wait_for_rx(struct qpnp_bsi_chip *chip, int timeout) /* Wait for RX IRQ to indicate that data is ready to read. */ while (timeout > 0) { if (qpnp_bsi_check_irq(chip, QPNP_BSI_IRQ_ERR)) { - dev_err(&chip->spmi_dev->dev, "%s: transaction error occurred, BSI error=%d\n", + dev_err(&chip->pdev->dev, + "%s: transaction error occurred, BSI error=%d\n", __func__, qpnp_bsi_get_bsi_error(chip)); return -EIO; } @@ -548,7 +563,8 @@ static int qpnp_bsi_bus_transaction(struct bif_ctrl_dev *bdev, int transaction, rc = qpnp_bsi_set_bus_state(bdev, BIF_BUS_STATE_ACTIVE); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: failed to set bus state, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: failed to set bus state, rc=%d\n", __func__, rc); return rc; } @@ -582,7 +598,8 @@ static int qpnp_bsi_bus_transaction_query(struct bif_ctrl_dev *bdev, rc = qpnp_bsi_set_bus_state(bdev, BIF_BUS_STATE_ACTIVE); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: failed to set bus state, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: failed to set bus state, rc=%d\n", __func__, rc); return rc; } @@ -628,7 +645,8 @@ static int qpnp_bsi_bus_transaction_read(struct bif_ctrl_dev *bdev, rc = qpnp_bsi_set_bus_state(bdev, BIF_BUS_STATE_ACTIVE); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: failed to set bus state, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: failed to set bus state, rc=%d\n", __func__, rc); return rc; } @@ -658,7 +676,8 @@ static int qpnp_bsi_bus_transaction_read(struct bif_ctrl_dev *bdev, * to provide silent operation when checking if a slave * is selected using the transaction query bus command. */ - dev_dbg(&chip->spmi_dev->dev, "%s: transaction timed out, no interrupts received, rc=%d\n", + dev_dbg(&chip->pdev->dev, + "%s: transaction timed out, no interrupts received, rc=%d\n", __func__, rc); } return rc; @@ -667,14 +686,16 @@ static int qpnp_bsi_bus_transaction_read(struct bif_ctrl_dev *bdev, /* Read the RX_DATA bytes. */ rc = qpnp_bsi_read(chip, QPNP_BSI_REG_RX_DATA_LOW, buf, 3); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_read() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_read() failed, rc=%d\n", __func__, rc); return rc; } if (buf[2] & QPNP_BSI_RX_SRC_LOOPBACK_FLAG) { rc = -EIO; - dev_err(&chip->spmi_dev->dev, "%s: unexpected loopback data read, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: unexpected loopback data read, rc=%d\n", __func__, rc); return rc; } @@ -702,13 +723,15 @@ static int qpnp_bsi_wait_for_rx_data(struct qpnp_bsi_chip *chip) while (timeout > 0) { rc = qpnp_bsi_read(chip, QPNP_BSI_REG_STATUS, ®, 1); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_write() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_write() failed, rc=%d\n", __func__, rc); return rc; } if (reg & QPNP_BSI_STATUS_ERROR) { - dev_err(&chip->spmi_dev->dev, "%s: transaction error occurred, BSI error=%d\n", + dev_err(&chip->pdev->dev, + "%s: transaction error occurred, BSI error=%d\n", __func__, qpnp_bsi_get_bsi_error(chip)); return -EIO; } @@ -723,7 +746,8 @@ static int qpnp_bsi_wait_for_rx_data(struct qpnp_bsi_chip *chip) } rc = -ETIMEDOUT; - dev_err(&chip->spmi_dev->dev, "%s: transaction timed out, RX_FLOW_STATUS never set to 1, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: transaction timed out, RX_FLOW_STATUS never set to 1, rc=%d\n", __func__, rc); return rc; @@ -745,13 +769,15 @@ static int qpnp_bsi_wait_for_tx_go(struct qpnp_bsi_chip *chip) while (timeout > 0) { rc = qpnp_bsi_read(chip, QPNP_BSI_REG_STATUS, ®, 1); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_write() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_write() failed, rc=%d\n", __func__, rc); return rc; } if (reg & QPNP_BSI_STATUS_ERROR) { - dev_err(&chip->spmi_dev->dev, "%s: transaction error occurred, BSI error=%d\n", + dev_err(&chip->pdev->dev, + "%s: transaction error occurred, BSI error=%d\n", __func__, qpnp_bsi_get_bsi_error(chip)); return -EIO; } @@ -766,7 +792,8 @@ static int qpnp_bsi_wait_for_tx_go(struct qpnp_bsi_chip *chip) } rc = -ETIMEDOUT; - dev_err(&chip->spmi_dev->dev, "%s: transaction timed out, TX_GO_STATUS never set to 0, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: transaction timed out, TX_GO_STATUS never set to 0, rc=%d\n", __func__, rc); return rc; @@ -788,13 +815,15 @@ static int qpnp_bsi_wait_for_tx_idle(struct qpnp_bsi_chip *chip) while (timeout > 0) { rc = qpnp_bsi_read(chip, QPNP_BSI_REG_STATUS, ®, 1); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_write() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_write() failed, rc=%d\n", __func__, rc); return rc; } if (reg & QPNP_BSI_STATUS_ERROR) { - dev_err(&chip->spmi_dev->dev, "%s: transaction error occurred, BSI error=%d\n", + dev_err(&chip->pdev->dev, + "%s: transaction error occurred, BSI error=%d\n", __func__, qpnp_bsi_get_bsi_error(chip)); return -EIO; } @@ -809,7 +838,8 @@ static int qpnp_bsi_wait_for_tx_idle(struct qpnp_bsi_chip *chip) } rc = -ETIMEDOUT; - dev_err(&chip->spmi_dev->dev, "%s: transaction timed out, TX_BUSY never set to 0, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: transaction timed out, TX_BUSY never set to 0, rc=%d\n", __func__, rc); return rc; @@ -872,23 +902,27 @@ static int qpnp_bsi_validate_rx_data(struct qpnp_bsi_chip *chip, int response, int err = -EIO; if (rx2_data & QPNP_BSI_RX_SRC_LOOPBACK_FLAG) { - dev_err(&chip->spmi_dev->dev, "%s: unexpected loopback data read, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: unexpected loopback data read, rc=%d\n", __func__, err); return err; } if (!(response & BIF_SLAVE_RD_ACK)) { - dev_err(&chip->spmi_dev->dev, "%s: BIF register read error=0x%02X\n", + dev_err(&chip->pdev->dev, + "%s: BIF register read error=0x%02X\n", __func__, response & BIF_SLAVE_RD_ERR); return err; } if (last_word && !(response & BIF_SLAVE_RD_EOT)) { - dev_err(&chip->spmi_dev->dev, "%s: BIF register read error, last RD packet has EOT=0\n", + dev_err(&chip->pdev->dev, + "%s: BIF register read error, last RD packet has EOT=0\n", __func__); return err; } else if (!last_word && (response & BIF_SLAVE_RD_EOT)) { - dev_err(&chip->spmi_dev->dev, "%s: BIF register read error, RD packet other than last has EOT=1\n", + dev_err(&chip->pdev->dev, + "%s: BIF register read error, RD packet other than last has EOT=1\n", __func__); return err; } @@ -910,7 +944,8 @@ static int qpnp_bsi_read_slave_registers(struct bif_ctrl_dev *bdev, u16 addr, rc = qpnp_bsi_set_bus_state(bdev, BIF_BUS_STATE_ACTIVE); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: failed to set bus state, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: failed to set bus state, rc=%d\n", __func__, rc); return rc; } @@ -957,7 +992,8 @@ static int qpnp_bsi_read_slave_registers(struct bif_ctrl_dev *bdev, u16 addr, rc = qpnp_bsi_read(chip, QPNP_BSI_REG_RX_DATA_LOW, buf, 3); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_read() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_read() failed, rc=%d\n", __func__, rc); goto burst_err; } @@ -1005,7 +1041,8 @@ static int qpnp_bsi_write_slave_registers(struct bif_ctrl_dev *bdev, u16 addr, rc = qpnp_bsi_set_bus_state(bdev, BIF_BUS_STATE_ACTIVE); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: failed to set bus state, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: failed to set bus state, rc=%d\n", __func__, rc); return rc; } @@ -1083,7 +1120,8 @@ static int qpnp_bsi_bus_set_interrupt_mode(struct bif_ctrl_dev *bdev) */ rc = qpnp_bsi_set_bus_state(bdev, BIF_BUS_STATE_ACTIVE); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: failed to set bus state, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: failed to set bus state, rc=%d\n", __func__, rc); return rc; } @@ -1138,7 +1176,8 @@ static int qpnp_bsi_bus_set_active_mode(struct bif_ctrl_dev *bdev, rc = qpnp_bsi_write(chip, QPNP_BSI_REG_MODE, buf, 2); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_write() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_write() failed, rc=%d\n", __func__, rc); return rc; } @@ -1147,7 +1186,8 @@ static int qpnp_bsi_bus_set_active_mode(struct bif_ctrl_dev *bdev, /* Initiate BCL low pulse. */ rc = qpnp_bsi_write(chip, QPNP_BSI_REG_TX_CTRL, buf, 1); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_write() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_write() failed, rc=%d\n", __func__, rc); return rc; } @@ -1195,7 +1235,8 @@ static int qpnp_bsi_set_bus_state(struct bif_ctrl_dev *bdev, int state) reg = QPNP_BSI_ENABLE; rc = qpnp_bsi_write(chip, QPNP_BSI_REG_ENABLE, ®, 1); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_write() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_write() failed, rc=%d\n", __func__, rc); return rc; } @@ -1207,25 +1248,29 @@ static int qpnp_bsi_set_bus_state(struct bif_ctrl_dev *bdev, int state) reg = QPNP_BSI_DISABLE; rc = qpnp_bsi_write(chip, QPNP_BSI_REG_ENABLE, ®, 1); if (rc) - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_write() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_write() failed, rc=%d\n", __func__, rc); break; case BIF_BUS_STATE_POWER_DOWN: rc = qpnp_bsi_bus_transaction(bdev, BIF_TRANS_BC, BIF_CMD_PDWN); if (rc) - dev_err(&chip->spmi_dev->dev, "%s: failed to enable power down mode, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: failed to enable power down mode, rc=%d\n", __func__, rc); break; case BIF_BUS_STATE_STANDBY: rc = qpnp_bsi_bus_transaction(bdev, BIF_TRANS_BC, BIF_CMD_STBY); if (rc) - dev_err(&chip->spmi_dev->dev, "%s: failed to enable standby mode, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: failed to enable standby mode, rc=%d\n", __func__, rc); break; case BIF_BUS_STATE_ACTIVE: rc = qpnp_bsi_bus_set_active_mode(bdev, chip->state); if (rc) - dev_err(&chip->spmi_dev->dev, "%s: failed to enable active mode, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: failed to enable active mode, rc=%d\n", __func__, rc); break; case BIF_BUS_STATE_INTERRUPT: @@ -1236,7 +1281,8 @@ static int qpnp_bsi_set_bus_state(struct bif_ctrl_dev *bdev, int state) */ rc = qpnp_bsi_bus_set_interrupt_mode(bdev); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: failed to enable interrupt mode, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: failed to enable interrupt mode, rc=%d\n", __func__, rc); } else if (chip->state == BIF_BUS_STATE_ACTIVE) { /* @@ -1249,7 +1295,7 @@ static int qpnp_bsi_set_bus_state(struct bif_ctrl_dev *bdev, int state) break; default: rc = -EINVAL; - dev_err(&chip->spmi_dev->dev, "%s: invalid state=%d\n", + dev_err(&chip->pdev->dev, "%s: invalid state=%d\n", __func__, state); } @@ -1329,7 +1375,8 @@ static int qpnp_bsi_set_tau_bif(struct qpnp_bsi_chip *chip, int period_ns) reg = chip->tau_sampling_mask | idx; rc = qpnp_bsi_write(chip, QPNP_BSI_REG_TAU_CONFIG, ®, 1); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: qpnp_bsi_write() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_bsi_write() failed, rc=%d\n", __func__, rc); return rc; } @@ -1361,7 +1408,8 @@ static int qpnp_bsi_get_battery_rid(struct bif_ctrl_dev *bdev) s64 temp; if (chip->batt_id_adc_channel >= ADC_MAX_NUM) { - dev_err(&chip->spmi_dev->dev, "%s: no ADC channel specified for Rid measurement\n", + dev_err(&chip->pdev->dev, + "%s: no ADC channel specified for Rid measurement\n", __func__); return -ENXIO; } @@ -1382,7 +1430,8 @@ static int qpnp_bsi_get_battery_rid(struct bif_ctrl_dev *bdev) rid_ohm = temp; } } else { - dev_err(&chip->spmi_dev->dev, "%s: qpnp_vadc_read(%d) failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: qpnp_vadc_read(%d) failed, rc=%d\n", __func__, chip->batt_id_adc_channel, rc); rid_ohm = rc; } @@ -1399,18 +1448,18 @@ static int qpnp_bsi_get_battery_rid(struct bif_ctrl_dev *bdev) static int qpnp_bsi_get_battery_presence(struct bif_ctrl_dev *bdev) { struct qpnp_bsi_chip *chip = bdev_get_drvdata(bdev); - u8 reg = 0x00; int rc; + uint val; - rc = spmi_ext_register_readl(chip->spmi_dev->ctrl, chip->spmi_dev->sid, - chip->batt_id_stat_addr, ®, 1); + rc = regmap_read(chip->regmap, chip->batt_id_stat_addr, &val); if (rc) { - dev_err(&chip->spmi_dev->dev, "%s: spmi_ext_register_readl() failed, rc=%d\n", + dev_err(&chip->pdev->dev, + "%s: regmap_bulk_readl failed, rc=%d\n", __func__, rc); return rc; } - return !!(reg & QPNP_SMBB_BAT_IF_BATT_PRES_MASK); + return !!(val & QPNP_SMBB_BAT_IF_BATT_PRES_MASK); } static struct bif_ctrl_ops qpnp_bsi_ops = { @@ -1429,11 +1478,11 @@ static struct bif_ctrl_ops qpnp_bsi_ops = { /* Load all BSI properties from device tree. */ static int qpnp_bsi_parse_dt(struct qpnp_bsi_chip *chip, - struct spmi_device *spmi) + struct platform_device *pdev) { - struct device *dev = &spmi->dev; - struct device_node *node = spmi->dev.of_node; - struct resource *res; + struct device *dev = &pdev->dev; + struct device_node *node = pdev->dev.of_node; + unsigned int base; int rc, temp; chip->batt_id_adc_channel = ADC_MAX_NUM; @@ -1466,27 +1515,28 @@ static int qpnp_bsi_parse_dt(struct qpnp_bsi_chip *chip, return -EINVAL; } - res = spmi_get_resource_byname(spmi, NULL, IORESOURCE_MEM, "bsi-base"); - if (!res) { - dev_err(dev, "%s: node is missing BSI base address\n", - __func__); - return -EINVAL; + rc = of_property_read_u32(pdev->dev.of_node, "bsi-base", &base); + if (rc < 0) { + dev_err(&pdev->dev, + "Couldn't find bsi-base in node = %s rc = %d\n", + pdev->dev.of_node->full_name, rc); + return rc; } - chip->base_addr = res->start; + chip->base_addr = base; - res = spmi_get_resource_byname(spmi, NULL, IORESOURCE_MEM, - "batt-id-status"); - if (!res) { - dev_err(dev, "%s: node is missing BATT_ID status address\n", - __func__); - return -EINVAL; + rc = of_property_read_u32(pdev->dev.of_node, "batt-id-status", &base); + if (rc < 0) { + dev_err(&pdev->dev, + "Couldn't find batt-if-status in node = %s rc = %d\n", + pdev->dev.of_node->full_name, rc); + return rc; } - chip->batt_id_stat_addr = res->start; + chip->batt_id_stat_addr = base; - chip->bdesc.name = spmi_get_primary_dev_name(spmi); + chip->bdesc.name = dev_name(&pdev->dev); if (!chip->bdesc.name) { dev_err(dev, "%s: label binding undefined for node %s\n", - __func__, spmi->dev.of_node->full_name); + __func__, pdev->dev.of_node->full_name); return -EINVAL; } @@ -1524,26 +1574,25 @@ static int qpnp_bsi_parse_dt(struct qpnp_bsi_chip *chip, return -EINVAL; } - chip->irq[QPNP_BSI_IRQ_ERR] = spmi_get_irq_byname(spmi, NULL, "err"); + chip->irq[QPNP_BSI_IRQ_ERR] = platform_get_irq_byname(pdev, "err"); if (chip->irq[QPNP_BSI_IRQ_ERR] < 0) { dev_err(dev, "%s: node is missing err irq\n", __func__); return chip->irq[QPNP_BSI_IRQ_ERR]; } - chip->irq[QPNP_BSI_IRQ_RX] = spmi_get_irq_byname(spmi, NULL, "rx"); + chip->irq[QPNP_BSI_IRQ_RX] = platform_get_irq_byname(pdev, "rx"); if (chip->irq[QPNP_BSI_IRQ_RX] < 0) { dev_err(dev, "%s: node is missing rx irq\n", __func__); return chip->irq[QPNP_BSI_IRQ_RX]; } - chip->irq[QPNP_BSI_IRQ_TX] = spmi_get_irq_byname(spmi, NULL, "tx"); + chip->irq[QPNP_BSI_IRQ_TX] = platform_get_irq_byname(pdev, "tx"); if (chip->irq[QPNP_BSI_IRQ_TX] < 0) { dev_err(dev, "%s: node is missing tx irq\n", __func__); return chip->irq[QPNP_BSI_IRQ_TX]; } - chip->batt_present_irq = spmi_get_irq_byname(spmi, NULL, - "batt-present"); + chip->batt_present_irq = platform_get_irq_byname(pdev, "batt-present"); if (chip->batt_present_irq < 0) { dev_err(dev, "%s: node is missing batt-present irq\n", __func__); @@ -1641,14 +1690,14 @@ static void qpnp_bsi_cleanup_irqs(struct qpnp_bsi_chip *chip) irq_set_irq_wake(chip->batt_present_irq, 0); } -static int qpnp_bsi_probe(struct spmi_device *spmi) +static int qpnp_bsi_probe(struct platform_device *pdev) { - struct device *dev = &spmi->dev; + struct device *dev = &pdev->dev; struct qpnp_bsi_chip *chip; int rc; u8 type[2]; - if (!spmi->dev.of_node) { + if (!pdev->dev.of_node) { dev_err(dev, "%s: device node missing\n", __func__); return -ENODEV; } @@ -1658,8 +1707,13 @@ static int qpnp_bsi_probe(struct spmi_device *spmi) dev_err(dev, "%s: Can't allocate qpnp_bsi\n", __func__); return -ENOMEM; } + chip->regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!chip->regmap) { + dev_err(&pdev->dev, "Couldn't get parent's regmap\n"); + return -EINVAL; + } - rc = qpnp_bsi_parse_dt(chip, spmi); + rc = qpnp_bsi_parse_dt(chip, pdev); if (rc) { dev_err(dev, "%s: device tree parsing failed, rc=%d\n", __func__, rc); @@ -1675,7 +1729,7 @@ static int qpnp_bsi_probe(struct spmi_device *spmi) return rc; } - chip->spmi_dev = spmi; + chip->pdev = pdev; chip->bdesc.ops = &qpnp_bsi_ops; chip->state = BIF_BUS_STATE_MASTER_DISABLED; chip->com_mode = QPNP_BSI_COM_MODE_IRQ; @@ -1714,7 +1768,7 @@ static int qpnp_bsi_probe(struct spmi_device *spmi) } chip->bdev = bif_ctrl_register(&chip->bdesc, dev, chip, - spmi->dev.of_node); + pdev->dev.of_node); if (IS_ERR(chip->bdev)) { rc = PTR_ERR(chip->bdev); dev_err(dev, "%s: bif_ctrl_register failed, rc=%d\n", @@ -1731,10 +1785,11 @@ cleanup_irqs: return rc; } -static int qpnp_bsi_remove(struct spmi_device *spmi) +static int qpnp_bsi_remove(struct platform_device *pdev) { - struct qpnp_bsi_chip *chip = dev_get_drvdata(&spmi->dev); - dev_set_drvdata(&spmi->dev, NULL); + struct qpnp_bsi_chip *chip = dev_get_drvdata(&pdev->dev); + + dev_set_drvdata(&pdev->dev, NULL); if (chip) { bif_ctrl_unregister(chip->bdev); @@ -1749,13 +1804,13 @@ static struct of_device_id spmi_match_table[] = { {} }; -static const struct spmi_device_id qpnp_bsi_id[] = { +static const struct platform_device_id qpnp_bsi_id[] = { { QPNP_BSI_DRIVER_NAME, 0 }, { } }; MODULE_DEVICE_TABLE(spmi, qpnp_bsi_id); -static struct spmi_driver qpnp_bsi_driver = { +static struct platform_driver qpnp_bsi_driver = { .driver = { .name = QPNP_BSI_DRIVER_NAME, .of_match_table = spmi_match_table, @@ -1768,12 +1823,12 @@ static struct spmi_driver qpnp_bsi_driver = { static int __init qpnp_bsi_init(void) { - return spmi_driver_register(&qpnp_bsi_driver); + return platform_driver_register(&qpnp_bsi_driver); } static void __exit qpnp_bsi_exit(void) { - spmi_driver_unregister(&qpnp_bsi_driver); + platform_driver_unregister(&qpnp_bsi_driver); } MODULE_DESCRIPTION("QPNP PMIC BSI driver"); |
