Lines Matching refs:bs
114 static void bcm63xx_hsspi_set_cs(struct bcm63xx_hsspi *bs, unsigned int cs, in bcm63xx_hsspi_set_cs() argument
119 mutex_lock(&bs->bus_mutex); in bcm63xx_hsspi_set_cs()
120 reg = __raw_readl(bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcm63xx_hsspi_set_cs()
123 if (active == !(bs->cs_polarity & BIT(cs))) in bcm63xx_hsspi_set_cs()
126 __raw_writel(reg, bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcm63xx_hsspi_set_cs()
127 mutex_unlock(&bs->bus_mutex); in bcm63xx_hsspi_set_cs()
130 static void bcm63xx_hsspi_set_clk(struct bcm63xx_hsspi *bs, in bcm63xx_hsspi_set_clk() argument
136 reg = DIV_ROUND_UP(2048, DIV_ROUND_UP(bs->speed_hz, hz)); in bcm63xx_hsspi_set_clk()
138 bs->regs + HSSPI_PROFILE_CLK_CTRL_REG(profile)); in bcm63xx_hsspi_set_clk()
140 reg = __raw_readl(bs->regs + HSSPI_PROFILE_SIGNAL_CTRL_REG(profile)); in bcm63xx_hsspi_set_clk()
145 __raw_writel(reg, bs->regs + HSSPI_PROFILE_SIGNAL_CTRL_REG(profile)); in bcm63xx_hsspi_set_clk()
147 mutex_lock(&bs->bus_mutex); in bcm63xx_hsspi_set_clk()
149 reg = __raw_readl(bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcm63xx_hsspi_set_clk()
153 __raw_writel(reg, bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcm63xx_hsspi_set_clk()
154 mutex_unlock(&bs->bus_mutex); in bcm63xx_hsspi_set_clk()
159 struct bcm63xx_hsspi *bs = spi_master_get_devdata(spi->master); in bcm63xx_hsspi_do_txrx() local
167 bcm63xx_hsspi_set_clk(bs, spi, t->speed_hz); in bcm63xx_hsspi_do_txrx()
168 bcm63xx_hsspi_set_cs(bs, spi->chip_select, true); in bcm63xx_hsspi_do_txrx()
186 bs->regs + HSSPI_PROFILE_MODE_CTRL_REG(chip_select)); in bcm63xx_hsspi_do_txrx()
191 reinit_completion(&bs->done); in bcm63xx_hsspi_do_txrx()
193 memcpy_toio(bs->fifo + HSSPI_OPCODE_LEN, tx, curr_step); in bcm63xx_hsspi_do_txrx()
197 __raw_writew(opcode | curr_step, bs->fifo); in bcm63xx_hsspi_do_txrx()
201 bs->regs + HSSPI_INT_MASK_REG); in bcm63xx_hsspi_do_txrx()
207 bs->regs + HSSPI_PINGPONG_COMMAND_REG(0)); in bcm63xx_hsspi_do_txrx()
209 if (wait_for_completion_timeout(&bs->done, HZ) == 0) { in bcm63xx_hsspi_do_txrx()
210 dev_err(&bs->pdev->dev, "transfer timed out!\n"); in bcm63xx_hsspi_do_txrx()
215 memcpy_fromio(rx, bs->fifo, curr_step); in bcm63xx_hsspi_do_txrx()
227 struct bcm63xx_hsspi *bs = spi_master_get_devdata(spi->master); in bcm63xx_hsspi_setup() local
230 reg = __raw_readl(bs->regs + in bcm63xx_hsspi_setup()
237 __raw_writel(reg, bs->regs + in bcm63xx_hsspi_setup()
240 mutex_lock(&bs->bus_mutex); in bcm63xx_hsspi_setup()
241 reg = __raw_readl(bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcm63xx_hsspi_setup()
244 if ((reg & GLOBAL_CTRL_CS_POLARITY_MASK) == bs->cs_polarity) { in bcm63xx_hsspi_setup()
249 __raw_writel(reg, bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcm63xx_hsspi_setup()
253 bs->cs_polarity |= BIT(spi->chip_select); in bcm63xx_hsspi_setup()
255 bs->cs_polarity &= ~BIT(spi->chip_select); in bcm63xx_hsspi_setup()
257 mutex_unlock(&bs->bus_mutex); in bcm63xx_hsspi_setup()
265 struct bcm63xx_hsspi *bs = spi_master_get_devdata(master); in bcm63xx_hsspi_transfer_one() local
287 bcm63xx_hsspi_set_cs(bs, dummy_cs, true); in bcm63xx_hsspi_transfer_one()
299 bcm63xx_hsspi_set_cs(bs, spi->chip_select, false); in bcm63xx_hsspi_transfer_one()
302 mutex_lock(&bs->bus_mutex); in bcm63xx_hsspi_transfer_one()
303 reg = __raw_readl(bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcm63xx_hsspi_transfer_one()
305 reg |= bs->cs_polarity; in bcm63xx_hsspi_transfer_one()
306 __raw_writel(reg, bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcm63xx_hsspi_transfer_one()
307 mutex_unlock(&bs->bus_mutex); in bcm63xx_hsspi_transfer_one()
317 struct bcm63xx_hsspi *bs = (struct bcm63xx_hsspi *)dev_id; in bcm63xx_hsspi_interrupt() local
319 if (__raw_readl(bs->regs + HSSPI_INT_STATUS_MASKED_REG) == 0) in bcm63xx_hsspi_interrupt()
322 __raw_writel(HSSPI_INT_CLEAR_ALL, bs->regs + HSSPI_INT_STATUS_REG); in bcm63xx_hsspi_interrupt()
323 __raw_writel(0, bs->regs + HSSPI_INT_MASK_REG); in bcm63xx_hsspi_interrupt()
325 complete(&bs->done); in bcm63xx_hsspi_interrupt()
333 struct bcm63xx_hsspi *bs; in bcm63xx_hsspi_probe() local
388 master = spi_alloc_master(&pdev->dev, sizeof(*bs)); in bcm63xx_hsspi_probe()
394 bs = spi_master_get_devdata(master); in bcm63xx_hsspi_probe()
395 bs->pdev = pdev; in bcm63xx_hsspi_probe()
396 bs->clk = clk; in bcm63xx_hsspi_probe()
397 bs->pll_clk = pll_clk; in bcm63xx_hsspi_probe()
398 bs->regs = regs; in bcm63xx_hsspi_probe()
399 bs->speed_hz = rate; in bcm63xx_hsspi_probe()
400 bs->fifo = (u8 __iomem *)(bs->regs + HSSPI_FIFO_REG(0)); in bcm63xx_hsspi_probe()
402 mutex_init(&bs->bus_mutex); in bcm63xx_hsspi_probe()
403 init_completion(&bs->done); in bcm63xx_hsspi_probe()
426 __raw_writel(0, bs->regs + HSSPI_INT_MASK_REG); in bcm63xx_hsspi_probe()
429 __raw_writel(HSSPI_INT_CLEAR_ALL, bs->regs + HSSPI_INT_STATUS_REG); in bcm63xx_hsspi_probe()
432 reg = __raw_readl(bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcm63xx_hsspi_probe()
433 bs->cs_polarity = reg & GLOBAL_CTRL_CS_POLARITY_MASK; in bcm63xx_hsspi_probe()
435 bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcm63xx_hsspi_probe()
438 pdev->name, bs); in bcm63xx_hsspi_probe()
467 struct bcm63xx_hsspi *bs = spi_master_get_devdata(master); in bcm63xx_hsspi_remove() local
470 __raw_writel(0, bs->regs + HSSPI_INT_MASK_REG); in bcm63xx_hsspi_remove()
471 clk_disable_unprepare(bs->pll_clk); in bcm63xx_hsspi_remove()
472 clk_disable_unprepare(bs->clk); in bcm63xx_hsspi_remove()
481 struct bcm63xx_hsspi *bs = spi_master_get_devdata(master); in bcm63xx_hsspi_suspend() local
484 clk_disable_unprepare(bs->pll_clk); in bcm63xx_hsspi_suspend()
485 clk_disable_unprepare(bs->clk); in bcm63xx_hsspi_suspend()
493 struct bcm63xx_hsspi *bs = spi_master_get_devdata(master); in bcm63xx_hsspi_resume() local
496 ret = clk_prepare_enable(bs->clk); in bcm63xx_hsspi_resume()
500 if (bs->pll_clk) { in bcm63xx_hsspi_resume()
501 ret = clk_prepare_enable(bs->pll_clk); in bcm63xx_hsspi_resume()
503 clk_disable_unprepare(bs->clk); in bcm63xx_hsspi_resume()