From: Scott Branden <scott.branden@broadcom.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: BCM Kernel Feedback <bcm-kernel-feedback-list@broadcom.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Shreesha Rajashekar <shreesha@broadcom.com>,
Scott Branden <scott.branden@broadcom.com>
Subject: [PATCH 2/3] w1: d1w: Provide callback for ds1wm read/write
Date: Wed, 16 Aug 2017 10:45:24 -0700 [thread overview]
Message-ID: <1502905525-5646-3-git-send-email-scott.branden@broadcom.com> (raw)
In-Reply-To: <1502905525-5646-1-git-send-email-scott.branden@broadcom.com>
From: Shreesha Rajashekar <shreesha@broadcom.com>
DS1WM core registers are accessed by reading from and writing to a group of
registers in iproc SOC's.
By default the read and write function uses
__raw_readb() and __raw_writeb(), which wouldnt work for iproc.
hence modifying to provide callbacks for read and write functions.
Signed-off-by: Shreesha Rajashekar <shreesha@broadcom.com>
Signed-off-by: Scott Branden <scott.branden@broadcom.com>
---
drivers/w1/masters/ds1wm.c | 18 ++++++++++++++++--
include/linux/mfd/ds1wm.h | 2 ++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index fd2e9da..9fadc39 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -115,12 +115,26 @@ struct ds1wm_data {
static inline void ds1wm_write_register(struct ds1wm_data *ds1wm_data, u32 reg,
u8 val)
{
- __raw_writeb(val, ds1wm_data->map + (reg << ds1wm_data->bus_shift));
+ struct device *dev = &ds1wm_data->pdev->dev;
+ struct ds1wm_driver_data *pdata = dev_get_platdata(dev);
+
+ if (pdata->write)
+ pdata->write(ds1wm_data->map, reg, val);
+ else
+ __raw_writeb(val, ds1wm_data->map +
+ (reg << ds1wm_data->bus_shift));
}
static inline u8 ds1wm_read_register(struct ds1wm_data *ds1wm_data, u32 reg)
{
- return __raw_readb(ds1wm_data->map + (reg << ds1wm_data->bus_shift));
+ struct device *dev = &ds1wm_data->pdev->dev;
+ struct ds1wm_driver_data *pdata = dev_get_platdata(dev);
+
+ if (pdata->read)
+ return pdata->read(ds1wm_data->map, reg);
+ else
+ return __raw_readb(ds1wm_data->map +
+ (reg << ds1wm_data->bus_shift));
}
diff --git a/include/linux/mfd/ds1wm.h b/include/linux/mfd/ds1wm.h
index 38a372a..c2d41d3 100644
--- a/include/linux/mfd/ds1wm.h
+++ b/include/linux/mfd/ds1wm.h
@@ -10,4 +10,6 @@ struct ds1wm_driver_data {
/* ds1wm implements the precise timings of*/
/* a reset pulse/presence detect sequence.*/
unsigned int reset_recover_delay;
+ void (*write)(void __iomem *map, u32 reg, u8 val);
+ u8 (*read)(void __iomem *map, u32 reg);
};
--
2.5.0
next prev parent reply other threads:[~2017-08-16 17:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-16 17:45 [PATCH 0/3] Add Support for Broadcom D1W controller Scott Branden
2017-08-16 17:45 ` [PATCH 1/3] dt-bindings: mfd: d1w: iproc: Documentation for d1w driver Scott Branden
2017-08-16 20:45 ` Rob Herring
2017-08-17 18:20 ` Scott Branden
2017-08-16 17:45 ` Scott Branden [this message]
2017-08-17 1:10 ` [PATCH 2/3] w1: d1w: Provide callback for ds1wm read/write Florian Fainelli
2017-08-16 17:45 ` [PATCH 3/3] mfd: d1w: iproc: Add d1w driver Scott Branden
2017-08-17 10:02 ` Lee Jones
2017-08-17 18:19 ` Scott Branden
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1502905525-5646-3-git-send-email-scott.branden@broadcom.com \
--to=scott.branden@broadcom.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shreesha@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®