Lines Matching refs:hw

147 	struct ppc4xx_spi *hw;  in spi_ppc4xx_txrx()  local
153 hw = spi_master_get_devdata(spi->master); in spi_ppc4xx_txrx()
155 hw->tx = t->tx_buf; in spi_ppc4xx_txrx()
156 hw->rx = t->rx_buf; in spi_ppc4xx_txrx()
157 hw->len = t->len; in spi_ppc4xx_txrx()
158 hw->count = 0; in spi_ppc4xx_txrx()
161 data = hw->tx ? hw->tx[0] : 0; in spi_ppc4xx_txrx()
162 out_8(&hw->regs->txd, data); in spi_ppc4xx_txrx()
163 out_8(&hw->regs->cr, SPI_PPC4XX_CR_STR); in spi_ppc4xx_txrx()
164 wait_for_completion(&hw->done); in spi_ppc4xx_txrx()
166 return hw->count; in spi_ppc4xx_txrx()
171 struct ppc4xx_spi *hw = spi_master_get_devdata(spi->master); in spi_ppc4xx_setupxfer() local
200 out_8(&hw->regs->mode, cs->mode); in spi_ppc4xx_setupxfer()
204 scr = (hw->opb_freq / speed) - 1; in spi_ppc4xx_setupxfer()
210 if (in_8(&hw->regs->cdm) != cdm) in spi_ppc4xx_setupxfer()
211 out_8(&hw->regs->cdm, cdm); in spi_ppc4xx_setupxfer()
213 mutex_lock(&hw->bitbang.lock); in spi_ppc4xx_setupxfer()
214 if (!hw->bitbang.busy) { in spi_ppc4xx_setupxfer()
215 hw->bitbang.chipselect(spi, BITBANG_CS_INACTIVE); in spi_ppc4xx_setupxfer()
218 mutex_unlock(&hw->bitbang.lock); in spi_ppc4xx_setupxfer()
268 struct ppc4xx_spi *hw = spi_master_get_devdata(spi->master); in spi_ppc4xx_chipsel() local
277 if (!hw->master->num_chipselect || hw->gpios[cs] == -EEXIST) in spi_ppc4xx_chipsel()
284 gpio_set_value(hw->gpios[cs], cspol); in spi_ppc4xx_chipsel()
289 struct ppc4xx_spi *hw; in spi_ppc4xx_int() local
294 hw = (struct ppc4xx_spi *)dev_id; in spi_ppc4xx_int()
296 status = in_8(&hw->regs->sr); in spi_ppc4xx_int()
310 dev_dbg(hw->dev, "got interrupt but spi still busy?\n"); in spi_ppc4xx_int()
313 lstatus = in_8(&hw->regs->sr); in spi_ppc4xx_int()
317 dev_err(hw->dev, "busywait: too many loops!\n"); in spi_ppc4xx_int()
318 complete(&hw->done); in spi_ppc4xx_int()
322 status = in_8(&hw->regs->sr); in spi_ppc4xx_int()
323 dev_dbg(hw->dev, "loops %d status %x\n", cnt, status); in spi_ppc4xx_int()
327 count = hw->count; in spi_ppc4xx_int()
328 hw->count++; in spi_ppc4xx_int()
331 data = in_8(&hw->regs->rxd); in spi_ppc4xx_int()
332 if (hw->rx) in spi_ppc4xx_int()
333 hw->rx[count] = data; in spi_ppc4xx_int()
337 if (count < hw->len) { in spi_ppc4xx_int()
338 data = hw->tx ? hw->tx[count] : 0; in spi_ppc4xx_int()
339 out_8(&hw->regs->txd, data); in spi_ppc4xx_int()
340 out_8(&hw->regs->cr, SPI_PPC4XX_CR_STR); in spi_ppc4xx_int()
342 complete(&hw->done); in spi_ppc4xx_int()
353 static void spi_ppc4xx_enable(struct ppc4xx_spi *hw) in spi_ppc4xx_enable() argument
365 static void free_gpios(struct ppc4xx_spi *hw) in free_gpios() argument
367 if (hw->master->num_chipselect) { in free_gpios()
369 for (i = 0; i < hw->master->num_chipselect; i++) in free_gpios()
370 if (gpio_is_valid(hw->gpios[i])) in free_gpios()
371 gpio_free(hw->gpios[i]); in free_gpios()
373 kfree(hw->gpios); in free_gpios()
374 hw->gpios = NULL; in free_gpios()
383 struct ppc4xx_spi *hw; in spi_ppc4xx_of_probe() local
394 master = spi_alloc_master(dev, sizeof *hw); in spi_ppc4xx_of_probe()
399 hw = spi_master_get_devdata(master); in spi_ppc4xx_of_probe()
400 hw->master = master; in spi_ppc4xx_of_probe()
401 hw->dev = dev; in spi_ppc4xx_of_probe()
403 init_completion(&hw->done); in spi_ppc4xx_of_probe()
414 hw->gpios = kzalloc(sizeof(int) * num_gpios, GFP_KERNEL); in spi_ppc4xx_of_probe()
415 if (!hw->gpios) { in spi_ppc4xx_of_probe()
425 hw->gpios[i] = gpio; in spi_ppc4xx_of_probe()
449 bbp = &hw->bitbang; in spi_ppc4xx_of_probe()
450 bbp->master = hw->master; in spi_ppc4xx_of_probe()
481 hw->opb_freq = *clk; in spi_ppc4xx_of_probe()
482 hw->opb_freq >>= 2; in spi_ppc4xx_of_probe()
490 hw->mapbase = resource.start; in spi_ppc4xx_of_probe()
491 hw->mapsize = resource_size(&resource); in spi_ppc4xx_of_probe()
494 if (hw->mapsize < sizeof(struct spi_ppc4xx_regs)) { in spi_ppc4xx_of_probe()
501 hw->irqnum = irq_of_parse_and_map(np, 0); in spi_ppc4xx_of_probe()
502 ret = request_irq(hw->irqnum, spi_ppc4xx_int, in spi_ppc4xx_of_probe()
503 0, "spi_ppc4xx_of", (void *)hw); in spi_ppc4xx_of_probe()
509 if (!request_mem_region(hw->mapbase, hw->mapsize, DRIVER_NAME)) { in spi_ppc4xx_of_probe()
515 hw->regs = ioremap(hw->mapbase, sizeof(struct spi_ppc4xx_regs)); in spi_ppc4xx_of_probe()
517 if (!hw->regs) { in spi_ppc4xx_of_probe()
523 spi_ppc4xx_enable(hw); in spi_ppc4xx_of_probe()
538 iounmap(hw->regs); in spi_ppc4xx_of_probe()
540 release_mem_region(hw->mapbase, hw->mapsize); in spi_ppc4xx_of_probe()
542 free_irq(hw->irqnum, hw); in spi_ppc4xx_of_probe()
544 free_gpios(hw); in spi_ppc4xx_of_probe()
555 struct ppc4xx_spi *hw = spi_master_get_devdata(master); in spi_ppc4xx_of_remove() local
557 spi_bitbang_stop(&hw->bitbang); in spi_ppc4xx_of_remove()
558 release_mem_region(hw->mapbase, hw->mapsize); in spi_ppc4xx_of_remove()
559 free_irq(hw->irqnum, hw); in spi_ppc4xx_of_remove()
560 iounmap(hw->regs); in spi_ppc4xx_of_remove()
561 free_gpios(hw); in spi_ppc4xx_of_remove()