Commit 6af36450 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Greg Kroah-Hartman

staging: spmi: hisi-spmi-controller: add debug when values are read/write

It is interesting to be able to check if the driver is doing
the right thing. So, add some debug macros to allow checking it.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/11dc4583c41a9c5e2804114d6a7a87374d2a23b4.1597647359.git.mchehab+huawei@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8788a30c
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#define SPMI_APB_SPMI_CMD_EN BIT(31) #define SPMI_APB_SPMI_CMD_EN BIT(31)
#define SPMI_APB_SPMI_CMD_TYPE_OFFSET 24 #define SPMI_APB_SPMI_CMD_TYPE_OFFSET 24
#define SPMI_APB_SPMI_CMD_LENGTH_OFFSET 20 #define SPMI_APB_SPMI_CMD_LENGTH_OFFSET 20
#define SPMI_APB_SPMI_CMD_SLAVEID_OFFSET 16 #define SPMI_APB_SPMI_CMD_SLAVEID_OFFSET 16
#define SPMI_APB_SPMI_CMD_ADDR_OFFSET 0 #define SPMI_APB_SPMI_CMD_ADDR_OFFSET 0
...@@ -135,10 +134,11 @@ static int spmi_controller_wait_for_done(struct spmi_controller_dev *ctrl_dev, ...@@ -135,10 +134,11 @@ static int spmi_controller_wait_for_done(struct spmi_controller_dev *ctrl_dev,
} }
static int spmi_read_cmd(struct spmi_controller *ctrl, static int spmi_read_cmd(struct spmi_controller *ctrl,
u8 opc, u8 sid, u16 addr, u8 *buf, size_t bc) u8 opc, u8 sid, u16 addr, u8 *__buf, size_t bc)
{ {
struct spmi_controller_dev *spmi_controller = dev_get_drvdata(&ctrl->dev); struct spmi_controller_dev *spmi_controller = dev_get_drvdata(&ctrl->dev);
unsigned long flags; unsigned long flags;
u8 *buf = __buf;
u32 cmd, data; u32 cmd, data;
int rc; int rc;
u32 chnl_ofst = SPMI_CHANNEL_OFFSET * spmi_controller->channel; u32 chnl_ofst = SPMI_CHANNEL_OFFSET * spmi_controller->channel;
...@@ -197,13 +197,18 @@ static int spmi_read_cmd(struct spmi_controller *ctrl, ...@@ -197,13 +197,18 @@ static int spmi_read_cmd(struct spmi_controller *ctrl,
if (rc) if (rc)
dev_err(spmi_controller->dev, "spmi read wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n", dev_err(spmi_controller->dev, "spmi read wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n",
opc, sid, addr, bc + 1); opc, sid, addr, bc + 1);
else
dev_dbg(spmi_controller->dev, "%s: id:%d addr:0x%x, read value: %*ph\n",
__func__, sid, addr, (int)bc, __buf);
return rc; return rc;
} }
static int spmi_write_cmd(struct spmi_controller *ctrl, static int spmi_write_cmd(struct spmi_controller *ctrl,
u8 opc, u8 sid, u16 addr, const u8 *buf, size_t bc) u8 opc, u8 sid, u16 addr, const u8 *__buf, size_t bc)
{ {
struct spmi_controller_dev *spmi_controller = dev_get_drvdata(&ctrl->dev); struct spmi_controller_dev *spmi_controller = dev_get_drvdata(&ctrl->dev);
const u8 *buf = __buf;
unsigned long flags; unsigned long flags;
u32 cmd, data; u32 cmd, data;
int rc; int rc;
...@@ -263,6 +268,9 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, ...@@ -263,6 +268,9 @@ static int spmi_write_cmd(struct spmi_controller *ctrl,
if (rc) if (rc)
dev_err(spmi_controller->dev, "spmi write wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n", dev_err(spmi_controller->dev, "spmi write wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n",
opc, sid, addr, bc); opc, sid, addr, bc);
else
dev_dbg(spmi_controller->dev, "%s: id:%d addr:0x%x, wrote value: %*ph\n",
__func__, sid, addr, (int)bc, __buf);
return rc; return rc;
} }
...@@ -275,6 +283,7 @@ static int spmi_controller_probe(struct platform_device *pdev) ...@@ -275,6 +283,7 @@ static int spmi_controller_probe(struct platform_device *pdev)
int ret = 0; int ret = 0;
dev_info(&pdev->dev, "HISI SPMI probe\n"); dev_info(&pdev->dev, "HISI SPMI probe\n");
ctrl = spmi_controller_alloc(&pdev->dev, sizeof(*spmi_controller)); ctrl = spmi_controller_alloc(&pdev->dev, sizeof(*spmi_controller));
if (!ctrl) { if (!ctrl) {
dev_err(&pdev->dev, "can not allocate spmi_controller data\n"); dev_err(&pdev->dev, "can not allocate spmi_controller data\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment