diff options
author | Kevin Cernekee <cernekee@gmail.com> | 2014-11-25 19:49:50 -0500 |
---|---|---|
committer | Florian Fainelli <f.fainelli@gmail.com> | 2014-11-28 18:44:43 -0500 |
commit | 2b53eadcea05b680278f8d078b166e1e295e2a4f (patch) | |
tree | 76a145fdacd100427c8ebcb297093f7f5176406d /drivers/bus | |
parent | dd1d78a11aecd68f5c688c3259c48b8ea4130aaa (diff) |
bus: brcmstb_gisb: Introduce wrapper functions for MMIO accesses
These will be used to abstract out chip-to-chip differences.
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Diffstat (limited to 'drivers/bus')
-rw-r--r-- | drivers/bus/brcmstb_gisb.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/drivers/bus/brcmstb_gisb.c b/drivers/bus/brcmstb_gisb.c index 5da935ad8d8b..8ff403da5d74 100644 --- a/drivers/bus/brcmstb_gisb.c +++ b/drivers/bus/brcmstb_gisb.c | |||
@@ -54,6 +54,16 @@ struct brcmstb_gisb_arb_device { | |||
54 | 54 | ||
55 | static LIST_HEAD(brcmstb_gisb_arb_device_list); | 55 | static LIST_HEAD(brcmstb_gisb_arb_device_list); |
56 | 56 | ||
57 | static u32 gisb_read(struct brcmstb_gisb_arb_device *gdev, int reg) | ||
58 | { | ||
59 | return ioread32(gdev->base + reg); | ||
60 | } | ||
61 | |||
62 | static void gisb_write(struct brcmstb_gisb_arb_device *gdev, u32 val, int reg) | ||
63 | { | ||
64 | iowrite32(val, gdev->base + reg); | ||
65 | } | ||
66 | |||
57 | static ssize_t gisb_arb_get_timeout(struct device *dev, | 67 | static ssize_t gisb_arb_get_timeout(struct device *dev, |
58 | struct device_attribute *attr, | 68 | struct device_attribute *attr, |
59 | char *buf) | 69 | char *buf) |
@@ -63,7 +73,7 @@ static ssize_t gisb_arb_get_timeout(struct device *dev, | |||
63 | u32 timeout; | 73 | u32 timeout; |
64 | 74 | ||
65 | mutex_lock(&gdev->lock); | 75 | mutex_lock(&gdev->lock); |
66 | timeout = ioread32(gdev->base + ARB_TIMER); | 76 | timeout = gisb_read(gdev, ARB_TIMER); |
67 | mutex_unlock(&gdev->lock); | 77 | mutex_unlock(&gdev->lock); |
68 | 78 | ||
69 | return sprintf(buf, "%d", timeout); | 79 | return sprintf(buf, "%d", timeout); |
@@ -85,7 +95,7 @@ static ssize_t gisb_arb_set_timeout(struct device *dev, | |||
85 | return -EINVAL; | 95 | return -EINVAL; |
86 | 96 | ||
87 | mutex_lock(&gdev->lock); | 97 | mutex_lock(&gdev->lock); |
88 | iowrite32(val, gdev->base + ARB_TIMER); | 98 | gisb_write(gdev, val, ARB_TIMER); |
89 | mutex_unlock(&gdev->lock); | 99 | mutex_unlock(&gdev->lock); |
90 | 100 | ||
91 | return count; | 101 | return count; |
@@ -112,18 +122,18 @@ static int brcmstb_gisb_arb_decode_addr(struct brcmstb_gisb_arb_device *gdev, | |||
112 | const char *m_name; | 122 | const char *m_name; |
113 | char m_fmt[11]; | 123 | char m_fmt[11]; |
114 | 124 | ||
115 | cap_status = ioread32(gdev->base + ARB_ERR_CAP_STATUS); | 125 | cap_status = gisb_read(gdev, ARB_ERR_CAP_STATUS); |
116 | 126 | ||
117 | /* Invalid captured address, bail out */ | 127 | /* Invalid captured address, bail out */ |
118 | if (!(cap_status & ARB_ERR_CAP_STATUS_VALID)) | 128 | if (!(cap_status & ARB_ERR_CAP_STATUS_VALID)) |
119 | return 1; | 129 | return 1; |
120 | 130 | ||
121 | /* Read the address and master */ | 131 | /* Read the address and master */ |
122 | arb_addr = ioread32(gdev->base + ARB_ERR_CAP_ADDR) & 0xffffffff; | 132 | arb_addr = gisb_read(gdev, ARB_ERR_CAP_ADDR) & 0xffffffff; |
123 | #if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT)) | 133 | #if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT)) |
124 | arb_addr |= (u64)ioread32(gdev->base + ARB_ERR_CAP_HI_ADDR) << 32; | 134 | arb_addr |= (u64)gisb_read(gdev, ARB_ERR_CAP_HI_ADDR) << 32; |
125 | #endif | 135 | #endif |
126 | master = ioread32(gdev->base + ARB_ERR_CAP_MASTER); | 136 | master = gisb_read(gdev, ARB_ERR_CAP_MASTER); |
127 | 137 | ||
128 | m_name = brcmstb_gisb_master_to_str(gdev, master); | 138 | m_name = brcmstb_gisb_master_to_str(gdev, master); |
129 | if (!m_name) { | 139 | if (!m_name) { |
@@ -138,7 +148,7 @@ static int brcmstb_gisb_arb_decode_addr(struct brcmstb_gisb_arb_device *gdev, | |||
138 | m_name); | 148 | m_name); |
139 | 149 | ||
140 | /* clear the GISB error */ | 150 | /* clear the GISB error */ |
141 | iowrite32(ARB_ERR_CAP_CLEAR, gdev->base + ARB_ERR_CAP_CLR); | 151 | gisb_write(gdev, ARB_ERR_CAP_CLEAR, ARB_ERR_CAP_CLR); |
142 | 152 | ||
143 | return 0; | 153 | return 0; |
144 | } | 154 | } |