Lines Matching refs:hw

100 	struct s3c24xx_spi *hw = to_hw(spi);  in s3c24xx_spi_chipsel()  local
107 hw->set_cs(hw->pdata, spi->chip_select, cspol^1); in s3c24xx_spi_chipsel()
108 writeb(cs->spcon, hw->regs + S3C2410_SPCON); in s3c24xx_spi_chipsel()
113 hw->regs + S3C2410_SPCON); in s3c24xx_spi_chipsel()
114 hw->set_cs(hw->pdata, spi->chip_select, cspol); in s3c24xx_spi_chipsel()
122 struct s3c24xx_spi *hw = to_hw(spi); in s3c24xx_spi_update_state() local
147 clk = clk_get_rate(hw->clk); in s3c24xx_spi_update_state()
167 struct s3c24xx_spi *hw = to_hw(spi); in s3c24xx_spi_setupxfer() local
172 writeb(cs->sppre, hw->regs + S3C2410_SPPRE); in s3c24xx_spi_setupxfer()
180 struct s3c24xx_spi *hw = to_hw(spi); in s3c24xx_spi_setup() local
201 mutex_lock(&hw->bitbang.lock); in s3c24xx_spi_setup()
202 if (!hw->bitbang.busy) { in s3c24xx_spi_setup()
203 hw->bitbang.chipselect(spi, BITBANG_CS_INACTIVE); in s3c24xx_spi_setup()
206 mutex_unlock(&hw->bitbang.lock); in s3c24xx_spi_setup()
211 static inline unsigned int hw_txbyte(struct s3c24xx_spi *hw, int count) in hw_txbyte() argument
213 return hw->tx ? hw->tx[count] : 0; in hw_txbyte()
263 static void s3c24xx_spi_tryfiq(struct s3c24xx_spi *hw) in s3c24xx_spi_tryfiq() argument
270 if (!hw->fiq_claimed) { in s3c24xx_spi_tryfiq()
274 ret = claim_fiq(&hw->fiq_handler); in s3c24xx_spi_tryfiq()
279 if (hw->tx && !hw->rx) in s3c24xx_spi_tryfiq()
281 else if (hw->rx && !hw->tx) in s3c24xx_spi_tryfiq()
286 regs.uregs[fiq_rspi] = (long)hw->regs; in s3c24xx_spi_tryfiq()
287 regs.uregs[fiq_rrx] = (long)hw->rx; in s3c24xx_spi_tryfiq()
288 regs.uregs[fiq_rtx] = (long)hw->tx + 1; in s3c24xx_spi_tryfiq()
289 regs.uregs[fiq_rcount] = hw->len - 1; in s3c24xx_spi_tryfiq()
294 if (hw->fiq_mode != mode) { in s3c24xx_spi_tryfiq()
297 hw->fiq_mode = mode; in s3c24xx_spi_tryfiq()
316 *ack_ptr = ack_bit(hw->irq); in s3c24xx_spi_tryfiq()
321 s3c24xx_set_fiq(hw->irq, true); in s3c24xx_spi_tryfiq()
323 hw->fiq_mode = mode; in s3c24xx_spi_tryfiq()
324 hw->fiq_inuse = 1; in s3c24xx_spi_tryfiq()
338 struct s3c24xx_spi *hw = pw; in s3c24xx_spi_fiqop() local
342 if (hw->fiq_inuse) in s3c24xx_spi_fiqop()
348 hw->fiq_mode = FIQ_MODE_NONE; in s3c24xx_spi_fiqop()
349 hw->fiq_claimed = 0; in s3c24xx_spi_fiqop()
351 hw->fiq_claimed = 1; in s3c24xx_spi_fiqop()
363 static inline void s3c24xx_spi_initfiq(struct s3c24xx_spi *hw) in s3c24xx_spi_initfiq() argument
365 hw->fiq_handler.dev_id = hw; in s3c24xx_spi_initfiq()
366 hw->fiq_handler.name = dev_name(hw->dev); in s3c24xx_spi_initfiq()
367 hw->fiq_handler.fiq_op = s3c24xx_spi_fiqop; in s3c24xx_spi_initfiq()
377 static inline bool s3c24xx_spi_usefiq(struct s3c24xx_spi *hw) in s3c24xx_spi_usefiq() argument
379 return hw->pdata->use_fiq; in s3c24xx_spi_usefiq()
404 struct s3c24xx_spi *hw = to_hw(spi); in s3c24xx_spi_txrx() local
406 hw->tx = t->tx_buf; in s3c24xx_spi_txrx()
407 hw->rx = t->rx_buf; in s3c24xx_spi_txrx()
408 hw->len = t->len; in s3c24xx_spi_txrx()
409 hw->count = 0; in s3c24xx_spi_txrx()
411 init_completion(&hw->done); in s3c24xx_spi_txrx()
413 hw->fiq_inuse = 0; in s3c24xx_spi_txrx()
414 if (s3c24xx_spi_usefiq(hw) && t->len >= 3) in s3c24xx_spi_txrx()
415 s3c24xx_spi_tryfiq(hw); in s3c24xx_spi_txrx()
418 writeb(hw_txbyte(hw, 0), hw->regs + S3C2410_SPTDAT); in s3c24xx_spi_txrx()
420 wait_for_completion(&hw->done); in s3c24xx_spi_txrx()
421 return hw->count; in s3c24xx_spi_txrx()
426 struct s3c24xx_spi *hw = dev; in s3c24xx_spi_irq() local
427 unsigned int spsta = readb(hw->regs + S3C2410_SPSTA); in s3c24xx_spi_irq()
428 unsigned int count = hw->count; in s3c24xx_spi_irq()
431 dev_dbg(hw->dev, "data-collision\n"); in s3c24xx_spi_irq()
432 complete(&hw->done); in s3c24xx_spi_irq()
437 dev_dbg(hw->dev, "spi not ready for tx?\n"); in s3c24xx_spi_irq()
438 complete(&hw->done); in s3c24xx_spi_irq()
442 if (!s3c24xx_spi_usingfiq(hw)) { in s3c24xx_spi_irq()
443 hw->count++; in s3c24xx_spi_irq()
445 if (hw->rx) in s3c24xx_spi_irq()
446 hw->rx[count] = readb(hw->regs + S3C2410_SPRDAT); in s3c24xx_spi_irq()
450 if (count < hw->len) in s3c24xx_spi_irq()
451 writeb(hw_txbyte(hw, count), hw->regs + S3C2410_SPTDAT); in s3c24xx_spi_irq()
453 complete(&hw->done); in s3c24xx_spi_irq()
455 hw->count = hw->len; in s3c24xx_spi_irq()
456 hw->fiq_inuse = 0; in s3c24xx_spi_irq()
458 if (hw->rx) in s3c24xx_spi_irq()
459 hw->rx[hw->len-1] = readb(hw->regs + S3C2410_SPRDAT); in s3c24xx_spi_irq()
461 complete(&hw->done); in s3c24xx_spi_irq()
468 static void s3c24xx_spi_initialsetup(struct s3c24xx_spi *hw) in s3c24xx_spi_initialsetup() argument
472 clk_enable(hw->clk); in s3c24xx_spi_initialsetup()
476 writeb(0xff, hw->regs + S3C2410_SPPRE); in s3c24xx_spi_initialsetup()
477 writeb(SPPIN_DEFAULT, hw->regs + S3C2410_SPPIN); in s3c24xx_spi_initialsetup()
478 writeb(SPCON_DEFAULT, hw->regs + S3C2410_SPCON); in s3c24xx_spi_initialsetup()
480 if (hw->pdata) { in s3c24xx_spi_initialsetup()
481 if (hw->set_cs == s3c24xx_spi_gpiocs) in s3c24xx_spi_initialsetup()
482 gpio_direction_output(hw->pdata->pin_cs, 1); in s3c24xx_spi_initialsetup()
484 if (hw->pdata->gpio_setup) in s3c24xx_spi_initialsetup()
485 hw->pdata->gpio_setup(hw->pdata, 1); in s3c24xx_spi_initialsetup()
492 struct s3c24xx_spi *hw; in s3c24xx_spi_probe() local
503 hw = spi_master_get_devdata(master); in s3c24xx_spi_probe()
505 hw->master = master; in s3c24xx_spi_probe()
506 hw->pdata = pdata = dev_get_platdata(&pdev->dev); in s3c24xx_spi_probe()
507 hw->dev = &pdev->dev; in s3c24xx_spi_probe()
515 platform_set_drvdata(pdev, hw); in s3c24xx_spi_probe()
516 init_completion(&hw->done); in s3c24xx_spi_probe()
520 s3c24xx_spi_initfiq(hw); in s3c24xx_spi_probe()
527 master->num_chipselect = hw->pdata->num_cs; in s3c24xx_spi_probe()
533 hw->bitbang.master = hw->master; in s3c24xx_spi_probe()
534 hw->bitbang.setup_transfer = s3c24xx_spi_setupxfer; in s3c24xx_spi_probe()
535 hw->bitbang.chipselect = s3c24xx_spi_chipsel; in s3c24xx_spi_probe()
536 hw->bitbang.txrx_bufs = s3c24xx_spi_txrx; in s3c24xx_spi_probe()
538 hw->master->setup = s3c24xx_spi_setup; in s3c24xx_spi_probe()
540 dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang); in s3c24xx_spi_probe()
544 hw->regs = devm_ioremap_resource(&pdev->dev, res); in s3c24xx_spi_probe()
545 if (IS_ERR(hw->regs)) { in s3c24xx_spi_probe()
546 err = PTR_ERR(hw->regs); in s3c24xx_spi_probe()
550 hw->irq = platform_get_irq(pdev, 0); in s3c24xx_spi_probe()
551 if (hw->irq < 0) { in s3c24xx_spi_probe()
557 err = devm_request_irq(&pdev->dev, hw->irq, s3c24xx_spi_irq, 0, in s3c24xx_spi_probe()
558 pdev->name, hw); in s3c24xx_spi_probe()
564 hw->clk = devm_clk_get(&pdev->dev, "spi"); in s3c24xx_spi_probe()
565 if (IS_ERR(hw->clk)) { in s3c24xx_spi_probe()
567 err = PTR_ERR(hw->clk); in s3c24xx_spi_probe()
587 hw->set_cs = s3c24xx_spi_gpiocs; in s3c24xx_spi_probe()
590 hw->set_cs = pdata->set_cs; in s3c24xx_spi_probe()
592 s3c24xx_spi_initialsetup(hw); in s3c24xx_spi_probe()
596 err = spi_bitbang_start(&hw->bitbang); in s3c24xx_spi_probe()
605 clk_disable(hw->clk); in s3c24xx_spi_probe()
608 spi_master_put(hw->master); in s3c24xx_spi_probe()
614 struct s3c24xx_spi *hw = platform_get_drvdata(dev); in s3c24xx_spi_remove() local
616 spi_bitbang_stop(&hw->bitbang); in s3c24xx_spi_remove()
617 clk_disable(hw->clk); in s3c24xx_spi_remove()
618 spi_master_put(hw->master); in s3c24xx_spi_remove()
627 struct s3c24xx_spi *hw = dev_get_drvdata(dev); in s3c24xx_spi_suspend() local
630 ret = spi_master_suspend(hw->master); in s3c24xx_spi_suspend()
634 if (hw->pdata && hw->pdata->gpio_setup) in s3c24xx_spi_suspend()
635 hw->pdata->gpio_setup(hw->pdata, 0); in s3c24xx_spi_suspend()
637 clk_disable(hw->clk); in s3c24xx_spi_suspend()
643 struct s3c24xx_spi *hw = dev_get_drvdata(dev); in s3c24xx_spi_resume() local
645 s3c24xx_spi_initialsetup(hw); in s3c24xx_spi_resume()
646 return spi_master_resume(hw->master); in s3c24xx_spi_resume()