Lines Matching refs:bs
130 struct bcmbca_hsspi *bs = spi_controller_get_devdata(ctrl); in wait_mode_show() local
132 return sprintf(buf, "%d\n", bs->wait_mode); in wait_mode_show()
139 struct bcmbca_hsspi *bs = spi_controller_get_devdata(ctrl); in wait_mode_store() local
150 mutex_lock(&bs->msg_mutex); in wait_mode_store()
151 bs->wait_mode = val; in wait_mode_store()
154 __raw_writel(HSSPI_INT_CLEAR_ALL, bs->regs + HSSPI_INT_STATUS_REG); in wait_mode_store()
155 mutex_unlock(&bs->msg_mutex); in wait_mode_store()
171 static void bcmbca_hsspi_set_cs(struct bcmbca_hsspi *bs, unsigned int cs, in bcmbca_hsspi_set_cs() argument
180 mutex_lock(&bs->bus_mutex); in bcmbca_hsspi_set_cs()
182 reg = __raw_readl(bs->spim_ctrl); in bcmbca_hsspi_set_cs()
188 __raw_writel(reg, bs->spim_ctrl); in bcmbca_hsspi_set_cs()
190 mutex_unlock(&bs->bus_mutex); in bcmbca_hsspi_set_cs()
193 static void bcmbca_hsspi_set_clk(struct bcmbca_hsspi *bs, in bcmbca_hsspi_set_clk() argument
199 reg = DIV_ROUND_UP(2048, DIV_ROUND_UP(bs->speed_hz, hz)); in bcmbca_hsspi_set_clk()
201 bs->regs + HSSPI_PROFILE_CLK_CTRL_REG(profile)); in bcmbca_hsspi_set_clk()
203 reg = __raw_readl(bs->regs + HSSPI_PROFILE_SIGNAL_CTRL_REG(profile)); in bcmbca_hsspi_set_clk()
208 __raw_writel(reg, bs->regs + HSSPI_PROFILE_SIGNAL_CTRL_REG(profile)); in bcmbca_hsspi_set_clk()
210 mutex_lock(&bs->bus_mutex); in bcmbca_hsspi_set_clk()
212 reg = __raw_readl(bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcmbca_hsspi_set_clk()
216 __raw_writel(reg, bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcmbca_hsspi_set_clk()
218 mutex_unlock(&bs->bus_mutex); in bcmbca_hsspi_set_clk()
221 static int bcmbca_hsspi_wait_cmd(struct bcmbca_hsspi *bs, unsigned int cs) in bcmbca_hsspi_wait_cmd() argument
227 if (bs->wait_mode == HSSPI_WAIT_MODE_INTR) { in bcmbca_hsspi_wait_cmd()
228 if (wait_for_completion_timeout(&bs->done, HZ) == 0) in bcmbca_hsspi_wait_cmd()
234 reg = __raw_readl(bs->regs + HSSPI_PINGPONG_STATUS_REG(0)); in bcmbca_hsspi_wait_cmd()
245 dev_err(&bs->pdev->dev, "transfer timed out!\n"); in bcmbca_hsspi_wait_cmd()
253 struct bcmbca_hsspi *bs = spi_controller_get_devdata(spi->controller); in bcmbca_hsspi_do_txrx() local
262 bcmbca_hsspi_set_clk(bs, spi, t->speed_hz); in bcmbca_hsspi_do_txrx()
285 bs->regs + HSSPI_PROFILE_MODE_CTRL_REG(chip_select)); in bcmbca_hsspi_do_txrx()
290 reinit_completion(&bs->done); in bcmbca_hsspi_do_txrx()
292 memcpy_toio(bs->fifo + HSSPI_OPCODE_LEN, tx, curr_step); in bcmbca_hsspi_do_txrx()
297 __raw_writew(val, bs->fifo); in bcmbca_hsspi_do_txrx()
300 if (bs->wait_mode == HSSPI_WAIT_MODE_INTR) in bcmbca_hsspi_do_txrx()
302 bs->regs + HSSPI_INT_MASK_REG); in bcmbca_hsspi_do_txrx()
306 bcmbca_hsspi_set_cs(bs, chip_select, true); in bcmbca_hsspi_do_txrx()
313 __raw_writel(reg, bs->regs + HSSPI_PINGPONG_COMMAND_REG(0)); in bcmbca_hsspi_do_txrx()
315 if (bcmbca_hsspi_wait_cmd(bs, spi_get_chipselect(spi, 0))) in bcmbca_hsspi_do_txrx()
321 memcpy_fromio(rx, bs->fifo, curr_step); in bcmbca_hsspi_do_txrx()
331 struct bcmbca_hsspi *bs = spi_controller_get_devdata(spi->controller); in bcmbca_hsspi_setup() local
334 reg = __raw_readl(bs->regs + in bcmbca_hsspi_setup()
341 __raw_writel(reg, bs->regs + in bcmbca_hsspi_setup()
344 mutex_lock(&bs->bus_mutex); in bcmbca_hsspi_setup()
345 reg = __raw_readl(bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcmbca_hsspi_setup()
351 __raw_writel(reg, bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcmbca_hsspi_setup()
354 bs->cs_polarity |= BIT(spi_get_chipselect(spi, 0)); in bcmbca_hsspi_setup()
356 bs->cs_polarity &= ~BIT(spi_get_chipselect(spi, 0)); in bcmbca_hsspi_setup()
358 reg = __raw_readl(bs->spim_ctrl); in bcmbca_hsspi_setup()
362 __raw_writel(reg, bs->spim_ctrl); in bcmbca_hsspi_setup()
364 mutex_unlock(&bs->bus_mutex); in bcmbca_hsspi_setup()
372 struct bcmbca_hsspi *bs = spi_controller_get_devdata(host); in bcmbca_hsspi_transfer_one() local
378 mutex_lock(&bs->msg_mutex); in bcmbca_hsspi_transfer_one()
391 bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), false); in bcmbca_hsspi_transfer_one()
396 bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), true); in bcmbca_hsspi_transfer_one()
400 bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), t->cs_off); in bcmbca_hsspi_transfer_one()
406 mutex_unlock(&bs->msg_mutex); in bcmbca_hsspi_transfer_one()
409 bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), false); in bcmbca_hsspi_transfer_one()
419 struct bcmbca_hsspi *bs = (struct bcmbca_hsspi *)dev_id; in bcmbca_hsspi_interrupt() local
421 if (__raw_readl(bs->regs + HSSPI_INT_STATUS_MASKED_REG) == 0) in bcmbca_hsspi_interrupt()
424 __raw_writel(HSSPI_INT_CLEAR_ALL, bs->regs + HSSPI_INT_STATUS_REG); in bcmbca_hsspi_interrupt()
425 __raw_writel(0, bs->regs + HSSPI_INT_MASK_REG); in bcmbca_hsspi_interrupt()
427 complete(&bs->done); in bcmbca_hsspi_interrupt()
435 struct bcmbca_hsspi *bs; in bcmbca_hsspi_probe() local
483 host = devm_spi_alloc_host(&pdev->dev, sizeof(*bs)); in bcmbca_hsspi_probe()
489 bs = spi_controller_get_devdata(host); in bcmbca_hsspi_probe()
490 bs->pdev = pdev; in bcmbca_hsspi_probe()
491 bs->clk = clk; in bcmbca_hsspi_probe()
492 bs->pll_clk = pll_clk; in bcmbca_hsspi_probe()
493 bs->regs = regs; in bcmbca_hsspi_probe()
494 bs->spim_ctrl = spim_ctrl; in bcmbca_hsspi_probe()
495 bs->speed_hz = rate; in bcmbca_hsspi_probe()
496 bs->fifo = (u8 __iomem *) (bs->regs + HSSPI_FIFO_REG(0)); in bcmbca_hsspi_probe()
497 bs->wait_mode = HSSPI_WAIT_MODE_POLLING; in bcmbca_hsspi_probe()
499 mutex_init(&bs->bus_mutex); in bcmbca_hsspi_probe()
500 mutex_init(&bs->msg_mutex); in bcmbca_hsspi_probe()
501 init_completion(&bs->done); in bcmbca_hsspi_probe()
524 __raw_writel(0, bs->regs + HSSPI_INT_MASK_REG); in bcmbca_hsspi_probe()
527 __raw_writel(HSSPI_INT_CLEAR_ALL, bs->regs + HSSPI_INT_STATUS_REG); in bcmbca_hsspi_probe()
530 reg = __raw_readl(bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcmbca_hsspi_probe()
531 bs->cs_polarity = reg & GLOBAL_CTRL_CS_POLARITY_MASK; in bcmbca_hsspi_probe()
533 bs->regs + HSSPI_GLOBAL_CTRL_REG); in bcmbca_hsspi_probe()
537 pdev->name, bs); in bcmbca_hsspi_probe()
573 struct bcmbca_hsspi *bs = spi_controller_get_devdata(host); in bcmbca_hsspi_remove() local
576 __raw_writel(0, bs->regs + HSSPI_INT_MASK_REG); in bcmbca_hsspi_remove()
577 clk_disable_unprepare(bs->pll_clk); in bcmbca_hsspi_remove()
578 clk_disable_unprepare(bs->clk); in bcmbca_hsspi_remove()
586 struct bcmbca_hsspi *bs = spi_controller_get_devdata(host); in bcmbca_hsspi_suspend() local
589 clk_disable_unprepare(bs->pll_clk); in bcmbca_hsspi_suspend()
590 clk_disable_unprepare(bs->clk); in bcmbca_hsspi_suspend()
598 struct bcmbca_hsspi *bs = spi_controller_get_devdata(host); in bcmbca_hsspi_resume() local
601 ret = clk_prepare_enable(bs->clk); in bcmbca_hsspi_resume()
605 if (bs->pll_clk) { in bcmbca_hsspi_resume()
606 ret = clk_prepare_enable(bs->pll_clk); in bcmbca_hsspi_resume()
608 clk_disable_unprepare(bs->clk); in bcmbca_hsspi_resume()