Lines Matching refs:hspi

46 static void hspi_write(struct hspi_priv *hspi, int reg, u32 val)  in hspi_write()  argument
48 iowrite32(val, hspi->addr + reg); in hspi_write()
51 static u32 hspi_read(struct hspi_priv *hspi, int reg) in hspi_read() argument
53 return ioread32(hspi->addr + reg); in hspi_read()
56 static void hspi_bit_set(struct hspi_priv *hspi, int reg, u32 mask, u32 set) in hspi_bit_set() argument
58 u32 val = hspi_read(hspi, reg); in hspi_bit_set()
63 hspi_write(hspi, reg, val); in hspi_bit_set()
69 static int hspi_status_check_timeout(struct hspi_priv *hspi, u32 mask, u32 val) in hspi_status_check_timeout() argument
74 if ((mask & hspi_read(hspi, SPSR)) == val) in hspi_status_check_timeout()
80 dev_err(hspi->dev, "timeout\n"); in hspi_status_check_timeout()
88 #define hspi_hw_cs_enable(hspi) hspi_hw_cs_ctrl(hspi, 0) argument
89 #define hspi_hw_cs_disable(hspi) hspi_hw_cs_ctrl(hspi, 1) argument
90 static void hspi_hw_cs_ctrl(struct hspi_priv *hspi, int hi) in hspi_hw_cs_ctrl() argument
92 hspi_bit_set(hspi, SPSCR, (1 << 6), (hi) << 6); in hspi_hw_cs_ctrl()
95 static void hspi_hw_setup(struct hspi_priv *hspi, in hspi_hw_setup() argument
100 struct device *dev = hspi->dev; in hspi_hw_setup()
111 rate = clk_get_rate(hspi->clk); in hspi_hw_setup()
138 hspi_write(hspi, SPCR, spcr); in hspi_hw_setup()
139 hspi_write(hspi, SPSR, 0x0); in hspi_hw_setup()
140 hspi_write(hspi, SPSCR, 0x21); /* master mode / CS control */ in hspi_hw_setup()
146 struct hspi_priv *hspi = spi_controller_get_devdata(ctlr); in hspi_transfer_one_message() local
154 dev_dbg(hspi->dev, "%s\n", __func__); in hspi_transfer_one_message()
161 hspi_hw_setup(hspi, msg, t); in hspi_transfer_one_message()
162 hspi_hw_cs_enable(hspi); in hspi_transfer_one_message()
170 ret = hspi_status_check_timeout(hspi, 0x1, 0); in hspi_transfer_one_message()
178 hspi_write(hspi, SPTBR, tx); in hspi_transfer_one_message()
181 ret = hspi_status_check_timeout(hspi, 0x4, 0x4); in hspi_transfer_one_message()
185 rx = hspi_read(hspi, SPRBR); in hspi_transfer_one_message()
197 hspi_hw_cs_disable(hspi); in hspi_transfer_one_message()
205 hspi_hw_cs_disable(hspi); in hspi_transfer_one_message()
216 struct hspi_priv *hspi; in hspi_probe() local
227 ctlr = spi_alloc_host(&pdev->dev, sizeof(*hspi)); in hspi_probe()
238 hspi = spi_controller_get_devdata(ctlr); in hspi_probe()
239 platform_set_drvdata(pdev, hspi); in hspi_probe()
242 hspi->ctlr = ctlr; in hspi_probe()
243 hspi->dev = &pdev->dev; in hspi_probe()
244 hspi->clk = clk; in hspi_probe()
245 hspi->addr = devm_ioremap(hspi->dev, in hspi_probe()
247 if (!hspi->addr) { in hspi_probe()
281 struct hspi_priv *hspi = platform_get_drvdata(pdev); in hspi_remove() local
285 clk_put(hspi->clk); in hspi_remove()