H A D | spi-sh-hspi.c | 54 static void hspi_write(struct hspi_priv *hspi, int reg, u32 val) hspi_write() argument 56 iowrite32(val, hspi->addr + reg); hspi_write() 59 static u32 hspi_read(struct hspi_priv *hspi, int reg) hspi_read() argument 61 return ioread32(hspi->addr + reg); hspi_read() 64 static void hspi_bit_set(struct hspi_priv *hspi, int reg, u32 mask, u32 set) hspi_bit_set() argument 66 u32 val = hspi_read(hspi, reg); hspi_bit_set() 71 hspi_write(hspi, reg, val); hspi_bit_set() 77 static int hspi_status_check_timeout(struct hspi_priv *hspi, u32 mask, u32 val) hspi_status_check_timeout() argument 82 if ((mask & hspi_read(hspi, SPSR)) == val) hspi_status_check_timeout() 88 dev_err(hspi->dev, "timeout\n"); hspi_status_check_timeout() 96 #define hspi_hw_cs_enable(hspi) hspi_hw_cs_ctrl(hspi, 0) 97 #define hspi_hw_cs_disable(hspi) hspi_hw_cs_ctrl(hspi, 1) hspi_hw_cs_ctrl() 98 static void hspi_hw_cs_ctrl(struct hspi_priv *hspi, int hi) hspi_hw_cs_ctrl() argument 100 hspi_bit_set(hspi, SPSCR, (1 << 6), (hi) << 6); hspi_hw_cs_ctrl() 103 static void hspi_hw_setup(struct hspi_priv *hspi, hspi_hw_setup() argument 108 struct device *dev = hspi->dev; hspi_hw_setup() 119 rate = clk_get_rate(hspi->clk); hspi_hw_setup() 146 hspi_write(hspi, SPCR, spcr); hspi_hw_setup() 147 hspi_write(hspi, SPSR, 0x0); hspi_hw_setup() 148 hspi_write(hspi, SPSCR, 0x21); /* master mode / CS control */ hspi_hw_setup() 154 struct hspi_priv *hspi = spi_master_get_devdata(master); hspi_transfer_one_message() local 162 dev_dbg(hspi->dev, "%s\n", __func__); hspi_transfer_one_message() 169 hspi_hw_setup(hspi, msg, t); hspi_transfer_one_message() 170 hspi_hw_cs_enable(hspi); hspi_transfer_one_message() 178 ret = hspi_status_check_timeout(hspi, 0x1, 0); hspi_transfer_one_message() 186 hspi_write(hspi, SPTBR, tx); hspi_transfer_one_message() 189 ret = hspi_status_check_timeout(hspi, 0x4, 0x4); hspi_transfer_one_message() 193 rx = hspi_read(hspi, SPRBR); hspi_transfer_one_message() 206 hspi_hw_cs_disable(hspi); hspi_transfer_one_message() 214 hspi_hw_cs_disable(hspi); hspi_transfer_one_message() 225 struct hspi_priv *hspi; hspi_probe() local 236 master = spi_alloc_master(&pdev->dev, sizeof(*hspi)); hspi_probe() 249 hspi = spi_master_get_devdata(master); hspi_probe() 250 platform_set_drvdata(pdev, hspi); hspi_probe() 252 /* init hspi */ hspi_probe() 253 hspi->master = master; hspi_probe() 254 hspi->dev = &pdev->dev; hspi_probe() 255 hspi->clk = clk; hspi_probe() 256 hspi->addr = devm_ioremap(hspi->dev, hspi_probe() 258 if (!hspi->addr) { hspi_probe() 293 struct hspi_priv *hspi = platform_get_drvdata(pdev); hspi_remove() local 297 clk_put(hspi->clk); hspi_remove() 303 { .compatible = "renesas,hspi", }, 312 .name = "sh-hspi", 321 MODULE_ALIAS("platform:sh-hspi");
|