Lines Matching refs:ssbi

66 struct ssbi {  struct
71 int (*read)(struct ssbi *, u16 addr, u8 *buf, int len); argument
72 int (*write)(struct ssbi *, u16 addr, const u8 *buf, int len); argument
75 static inline u32 ssbi_readl(struct ssbi *ssbi, u32 reg) in ssbi_readl() argument
77 return readl(ssbi->base + reg); in ssbi_readl()
80 static inline void ssbi_writel(struct ssbi *ssbi, u32 val, u32 reg) in ssbi_writel() argument
82 writel(val, ssbi->base + reg); in ssbi_writel()
94 static int ssbi_wait_mask(struct ssbi *ssbi, u32 set_mask, u32 clr_mask) in ssbi_wait_mask() argument
100 val = ssbi_readl(ssbi, SSBI2_STATUS); in ssbi_wait_mask()
110 ssbi_read_bytes(struct ssbi *ssbi, u16 addr, u8 *buf, int len) in ssbi_read_bytes() argument
115 if (ssbi->controller_type == MSM_SBI_CTRL_SSBI2) { in ssbi_read_bytes()
116 u32 mode2 = ssbi_readl(ssbi, SSBI2_MODE2); in ssbi_read_bytes()
118 ssbi_writel(ssbi, mode2, SSBI2_MODE2); in ssbi_read_bytes()
122 ret = ssbi_wait_mask(ssbi, SSBI_STATUS_READY, 0); in ssbi_read_bytes()
126 ssbi_writel(ssbi, cmd, SSBI2_CMD); in ssbi_read_bytes()
127 ret = ssbi_wait_mask(ssbi, SSBI_STATUS_RD_READY, 0); in ssbi_read_bytes()
130 *buf++ = ssbi_readl(ssbi, SSBI2_RD) & 0xff; in ssbi_read_bytes()
139 ssbi_write_bytes(struct ssbi *ssbi, u16 addr, const u8 *buf, int len) in ssbi_write_bytes() argument
143 if (ssbi->controller_type == MSM_SBI_CTRL_SSBI2) { in ssbi_write_bytes()
144 u32 mode2 = ssbi_readl(ssbi, SSBI2_MODE2); in ssbi_write_bytes()
146 ssbi_writel(ssbi, mode2, SSBI2_MODE2); in ssbi_write_bytes()
150 ret = ssbi_wait_mask(ssbi, SSBI_STATUS_READY, 0); in ssbi_write_bytes()
154 ssbi_writel(ssbi, ((addr & 0xff) << 16) | *buf, SSBI2_CMD); in ssbi_write_bytes()
155 ret = ssbi_wait_mask(ssbi, 0, SSBI_STATUS_MCHN_BUSY); in ssbi_write_bytes()
171 ssbi_pa_transfer(struct ssbi *ssbi, u32 cmd, u8 *data) in ssbi_pa_transfer() argument
176 ssbi_writel(ssbi, cmd, SSBI_PA_CMD); in ssbi_pa_transfer()
179 rd_status = ssbi_readl(ssbi, SSBI_PA_RD_STATUS); in ssbi_pa_transfer()
196 ssbi_pa_read_bytes(struct ssbi *ssbi, u16 addr, u8 *buf, int len) in ssbi_pa_read_bytes() argument
204 ret = ssbi_pa_transfer(ssbi, cmd, buf); in ssbi_pa_read_bytes()
216 ssbi_pa_write_bytes(struct ssbi *ssbi, u16 addr, const u8 *buf, int len) in ssbi_pa_write_bytes() argument
223 ret = ssbi_pa_transfer(ssbi, cmd, NULL); in ssbi_pa_write_bytes()
236 struct ssbi *ssbi = dev_get_drvdata(dev); in ssbi_read() local
240 spin_lock_irqsave(&ssbi->lock, flags); in ssbi_read()
241 ret = ssbi->read(ssbi, addr, buf, len); in ssbi_read()
242 spin_unlock_irqrestore(&ssbi->lock, flags); in ssbi_read()
250 struct ssbi *ssbi = dev_get_drvdata(dev); in ssbi_write() local
254 spin_lock_irqsave(&ssbi->lock, flags); in ssbi_write()
255 ret = ssbi->write(ssbi, addr, buf, len); in ssbi_write()
256 spin_unlock_irqrestore(&ssbi->lock, flags); in ssbi_write()
265 struct ssbi *ssbi; in ssbi_probe() local
268 ssbi = devm_kzalloc(&pdev->dev, sizeof(*ssbi), GFP_KERNEL); in ssbi_probe()
269 if (!ssbi) in ssbi_probe()
272 ssbi->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in ssbi_probe()
273 if (IS_ERR(ssbi->base)) in ssbi_probe()
274 return PTR_ERR(ssbi->base); in ssbi_probe()
276 platform_set_drvdata(pdev, ssbi); in ssbi_probe()
285 ssbi->controller_type = MSM_SBI_CTRL_SSBI; in ssbi_probe()
287 ssbi->controller_type = MSM_SBI_CTRL_SSBI2; in ssbi_probe()
289 ssbi->controller_type = MSM_SBI_CTRL_PMIC_ARBITER; in ssbi_probe()
295 if (ssbi->controller_type == MSM_SBI_CTRL_PMIC_ARBITER) { in ssbi_probe()
296 ssbi->read = ssbi_pa_read_bytes; in ssbi_probe()
297 ssbi->write = ssbi_pa_write_bytes; in ssbi_probe()
299 ssbi->read = ssbi_read_bytes; in ssbi_probe()
300 ssbi->write = ssbi_write_bytes; in ssbi_probe()
303 spin_lock_init(&ssbi->lock); in ssbi_probe()