int spi_cs_is_valid(unsigned int bus, unsigned int cs) { if (is_gpio_cs(cs)) return gpio_is_valid(gpio_cs(cs)); else return (cs >= 1 && cs <= MAX_CTRL_CS); }
void spi_cs_deactivate(struct spi_slave *slave) { struct bfin_spi_slave *bss = to_bfin_spi_slave(slave); if (is_gpio_cs(slave->cs)) { unsigned int cs = gpio_cs(slave->cs); gpio_set_value(cs, !bss->flg); debug("%s: SPI_CS_GPIO:%x\n", __func__, gpio_get_value(cs)); } else { u16 flg; /* make sure we force the cs to deassert rather than let the * pin float back up. otherwise, exact timings may not be * met some of the time leading to random behavior (ugh). */ flg = read_SPI_FLG(bss) | ((!bss->flg << 8) << slave->cs); write_SPI_FLG(bss, flg); SSYNC(); debug("%s: SPI_FLG:%x\n", __func__, read_SPI_FLG(bss)); flg &= ~(1 << slave->cs); write_SPI_FLG(bss, flg); debug("%s: SPI_FLG:%x\n", __func__, read_SPI_FLG(bss)); } SSYNC(); }
void spi_release_bus(struct spi_slave *slave) { struct bfin_spi_slave *bss = to_bfin_spi_slave(slave); debug("%s: bus:%i cs:%i\n", __func__, slave->bus, slave->cs); peripheral_free_list(pins[slave->bus]); if (is_gpio_cs(slave->cs)) gpio_free(gpio_cs(slave->cs)); write_SPI_CTL(bss, 0); SSYNC(); }
void spi_release_bus(struct spi_slave *slave) { struct bfin_spi_slave *bss = to_bfin_spi_slave(slave); debug("%s: bus:%i cs:%i\n", __func__, slave->bus, slave->cs); peripheral_free_list(pins[slave->bus]); if (is_gpio_cs(slave->cs)) gpio_free(gpio_cs(slave->cs)); bfin_write32(&bss->regs->rx_control, 0x0); bfin_write32(&bss->regs->tx_control, 0x0); bfin_write32(&bss->regs->control, 0x0); SSYNC(); }
void spi_cs_activate(struct spi_slave *slave) { struct bfin_spi_slave *bss = to_bfin_spi_slave(slave); if (is_gpio_cs(slave->cs)) { unsigned int cs = gpio_cs(slave->cs); gpio_set_value(cs, bss->flg); debug("%s: SPI_CS_GPIO:%x\n", __func__, gpio_get_value(cs)); } else { write_SPI_FLG(bss, (read_SPI_FLG(bss) & ~((!bss->flg << 8) << slave->cs)) | (1 << slave->cs)); debug("%s: SPI_FLG:%x\n", __func__, read_SPI_FLG(bss)); } SSYNC(); }
void spi_cs_activate(struct spi_slave *slave) { struct bfin_spi_slave *bss = to_bfin_spi_slave(slave); if (is_gpio_cs(slave->cs)) { unsigned int cs = gpio_cs(slave->cs); gpio_set_value(cs, bss->cs_pol); } else { u32 ssel; ssel = bfin_read32(&bss->regs->ssel); ssel |= 1 << slave->cs; if (bss->cs_pol) ssel |= BIT(8) << slave->cs; else ssel &= ~(BIT(8) << slave->cs); bfin_write32(&bss->regs->ssel, ssel); } SSYNC(); }
int spi_claim_bus(struct spi_slave *slave) { struct bfin_spi_slave *bss = to_bfin_spi_slave(slave); debug("%s: bus:%i cs:%i\n", __func__, slave->bus, slave->cs); if (is_gpio_cs(slave->cs)) { unsigned int cs = gpio_cs(slave->cs); gpio_request(cs, "bfin-spi"); gpio_direction_output(cs, !bss->flg); pins[slave->bus][0] = P_DONTCARE; } else pins[slave->bus][0] = cs_pins[slave->bus][slave->cs - 1]; peripheral_request_list(pins[slave->bus], "bfin-spi"); write_SPI_CTL(bss, bss->ctl); write_SPI_BAUD(bss, bss->baud); SSYNC(); return 0; }
int spi_claim_bus(struct spi_slave *slave) { struct bfin_spi_slave *bss = to_bfin_spi_slave(slave); debug("%s: bus:%i cs:%i\n", __func__, slave->bus, slave->cs); if (is_gpio_cs(slave->cs)) { unsigned int cs = gpio_cs(slave->cs); gpio_request(cs, "bfin-spi"); gpio_direction_output(cs, !bss->cs_pol); pins[slave->bus][0] = P_DONTCARE; } else pins[slave->bus][0] = cs_pins[slave->bus][slave->cs - 1]; peripheral_request_list(pins[slave->bus], "bfin-spi"); bfin_write32(&bss->regs->control, bss->control); bfin_write32(&bss->regs->clock, bss->clock); bfin_write32(&bss->regs->delay, 0x0); bfin_write32(&bss->regs->rx_control, SPI_RXCTL_REN); bfin_write32(&bss->regs->tx_control, SPI_TXCTL_TEN | SPI_TXCTL_TTI); SSYNC(); return 0; }
void spi_cs_deactivate(struct spi_slave *slave) { struct bfin_spi_slave *bss = to_bfin_spi_slave(slave); if (is_gpio_cs(slave->cs)) { unsigned int cs = gpio_cs(slave->cs); gpio_set_value(cs, !bss->cs_pol); } else { u32 ssel; ssel = bfin_read32(&bss->regs->ssel); if (bss->cs_pol) ssel &= ~((1 << 8) << slave->cs); else ssel |= (1 << 8) << slave->cs; /* deassert cs */ bfin_write32(&bss->regs->ssel, ssel); SSYNC(); /* disable cs */ ssel &= ~(1 << slave->cs); bfin_write32(&bss->regs->ssel, ssel); } SSYNC(); }