Lines Matching refs:hw

72 	struct altera_spi *hw = altera_spi_to_hw(spi);
78 hw->base + ALTERA_SPI_SLAVE_SEL);
79 hw->imr |= ALTERA_SPI_CONTROL_SSO_MSK;
80 writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
84 hw->imr &= ~ALTERA_SPI_CONTROL_SSO_MSK;
85 writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
86 writel(0, hw->base + ALTERA_SPI_SLAVE_SEL);
92 hw->imr &= ~ALTERA_SPI_CONTROL_SSO_MSK;
93 writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
98 hw->base + ALTERA_SPI_SLAVE_SEL);
99 hw->imr |= ALTERA_SPI_CONTROL_SSO_MSK;
100 writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
116 static inline unsigned int hw_txbyte(struct altera_spi *hw, int count)
118 if (hw->tx) {
119 switch (hw->bytes_per_word) {
121 return hw->tx[count];
123 return (hw->tx[count * 2]
124 | (hw->tx[count * 2 + 1] << 8));
132 struct altera_spi *hw = altera_spi_to_hw(spi);
134 hw->tx = t->tx_buf;
135 hw->rx = t->rx_buf;
136 hw->count = 0;
137 hw->bytes_per_word = (t->bits_per_word ? : spi->bits_per_word) / 8;
138 hw->len = t->len / hw->bytes_per_word;
140 if (hw->irq >= 0) {
142 hw->imr |= ALTERA_SPI_CONTROL_IRRDY_MSK;
143 writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
146 writel(hw_txbyte(hw, 0), hw->base + ALTERA_SPI_TXDATA);
148 wait_for_completion(&hw->done);
150 hw->imr &= ~ALTERA_SPI_CONTROL_IRRDY_MSK;
151 writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
154 writel(hw_txbyte(hw, 0), hw->base + ALTERA_SPI_TXDATA);
159 while (!(readl(hw->base + ALTERA_SPI_STATUS) &
163 rxd = readl(hw->base + ALTERA_SPI_RXDATA);
164 if (hw->rx) {
165 switch (hw->bytes_per_word) {
167 hw->rx[hw->count] = rxd;
170 hw->rx[hw->count * 2] = rxd;
171 hw->rx[hw->count * 2 + 1] = rxd >> 8;
176 hw->count++;
178 if (hw->count < hw->len)
179 writel(hw_txbyte(hw, hw->count),
180 hw->base + ALTERA_SPI_TXDATA);
187 return hw->count * hw->bytes_per_word;
192 struct altera_spi *hw = dev;
195 rxd = readl(hw->base + ALTERA_SPI_RXDATA);
196 if (hw->rx) {
197 switch (hw->bytes_per_word) {
199 hw->rx[hw->count] = rxd;
202 hw->rx[hw->count * 2] = rxd;
203 hw->rx[hw->count * 2 + 1] = rxd >> 8;
208 hw->count++;
210 if (hw->count < hw->len)
211 writel(hw_txbyte(hw, hw->count), hw->base + ALTERA_SPI_TXDATA);
213 complete(&hw->done);
221 struct altera_spi *hw;
236 hw = spi_master_get_devdata(master);
237 platform_set_drvdata(pdev, hw);
240 hw->bitbang.master = spi_master_get(master);
241 if (!hw->bitbang.master)
243 hw->bitbang.setup_transfer = altera_spi_setupxfer;
244 hw->bitbang.chipselect = altera_spi_chipsel;
245 hw->bitbang.txrx_bufs = altera_spi_txrx;
254 hw->base = devm_ioremap_nocache(&pdev->dev, res->start,
256 if (!hw->base)
259 hw->imr = 0; /* disable spi interrupts */
260 writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
261 writel(0, hw->base + ALTERA_SPI_STATUS); /* clear status reg */
262 if (readl(hw->base + ALTERA_SPI_STATUS) & ALTERA_SPI_STATUS_RRDY_MSK)
263 readl(hw->base + ALTERA_SPI_RXDATA); /* flush rxdata */
265 hw->irq = platform_get_irq(pdev, 0);
266 if (hw->irq >= 0) {
267 init_completion(&hw->done);
268 err = devm_request_irq(&pdev->dev, hw->irq, altera_spi_irq, 0,
269 pdev->name, hw);
275 hw->bitbang.master->dev.of_node = pdev->dev.of_node;
278 err = spi_bitbang_start(&hw->bitbang);
281 dev_info(&pdev->dev, "base %p, irq %d\n", hw->base, hw->irq);
295 struct altera_spi *hw = platform_get_drvdata(dev);
296 struct spi_master *master = hw->bitbang.master;
298 spi_bitbang_stop(&hw->bitbang);