Lines Matching refs:ns

95 static int __atcspi200_spi_set_speed(struct nds_spi_slave *ns)  in __atcspi200_spi_set_speed()  argument
99 tm = ns->regs->timing; in __atcspi200_spi_set_speed()
102 if(ns->freq >= ns->clock) in __atcspi200_spi_set_speed()
106 if (ns->freq >= ns->clock / (2 * (div + 1))) in __atcspi200_spi_set_speed()
112 ns->regs->timing = tm; in __atcspi200_spi_set_speed()
118 static int __atcspi200_spi_claim_bus(struct nds_spi_slave *ns) in __atcspi200_spi_claim_bus() argument
121 ns->regs->ctrl |= (TXFRST|RXFRST|SPIRST); in __atcspi200_spi_claim_bus()
122 while((ns->regs->ctrl &(TXFRST|RXFRST|SPIRST))&&(ns->to--)) in __atcspi200_spi_claim_bus()
123 if(!ns->to) in __atcspi200_spi_claim_bus()
126 ns->cmd_len = 0; in __atcspi200_spi_claim_bus()
127 format = ns->mode|DATA_LENGTH(8); in __atcspi200_spi_claim_bus()
128 ns->regs->format = format; in __atcspi200_spi_claim_bus()
129 __atcspi200_spi_set_speed(ns); in __atcspi200_spi_claim_bus()
134 static int __atcspi200_spi_release_bus(struct nds_spi_slave *ns) in __atcspi200_spi_release_bus() argument
140 static int __atcspi200_spi_start(struct nds_spi_slave *ns) in __atcspi200_spi_start() argument
143 int tc = ns->regs->tctrl; in __atcspi200_spi_start()
146 if ((ns->din)&&(ns->cmd_len)) in __atcspi200_spi_start()
148 else if (ns->din) in __atcspi200_spi_start()
153 if(ns->dout) in __atcspi200_spi_start()
154 olen = ns->tran_len; in __atcspi200_spi_start()
155 tc |= (ns->cmd_len+olen-1) << WCNT_OFFSET; in __atcspi200_spi_start()
157 if(ns->din) in __atcspi200_spi_start()
158 tc |= (ns->tran_len-1) << RCNT_OFFSET; in __atcspi200_spi_start()
160 ns->regs->tctrl = tc; in __atcspi200_spi_start()
161 ns->regs->cmd = 1; in __atcspi200_spi_start()
163 for (i=0;i<ns->cmd_len;i++) in __atcspi200_spi_start()
164 ns->regs->data = ns->cmd_buf[i]; in __atcspi200_spi_start()
169 static int __atcspi200_spi_stop(struct nds_spi_slave *ns) in __atcspi200_spi_stop() argument
171 ns->regs->timing = ns->mtiming; in __atcspi200_spi_stop()
172 while ((ns->regs->status & SPIBSY)&&(ns->to--)) in __atcspi200_spi_stop()
173 if (!ns->to) in __atcspi200_spi_stop()
179 static void __nspi_espi_tx(struct nds_spi_slave *ns, const void *dout) in __nspi_espi_tx() argument
181 ns->regs->data = *(u8 *)dout; in __nspi_espi_tx()
184 static int __nspi_espi_rx(struct nds_spi_slave *ns, void *din, unsigned int bytes) in __nspi_espi_rx() argument
186 *(u8 *)din = ns->regs->data; in __nspi_espi_rx()
191 static int __atcspi200_spi_xfer(struct nds_spi_slave *ns, in __atcspi200_spi_xfer() argument
200 u8 *cmd_buf = ns->cmd_buf; in __atcspi200_spi_xfer()
201 size_t cmd_len = ns->cmd_len; in __atcspi200_spi_xfer()
206 max_tran_len = ns->max_transfer_length; in __atcspi200_spi_xfer()
209 cmd_len = ns->cmd_len = data_len; in __atcspi200_spi_xfer()
218 ns->data_len = data_len; in __atcspi200_spi_xfer()
219 ns->din = (u8 *)data_in; in __atcspi200_spi_xfer()
220 ns->dout = (u8 *)data_out; in __atcspi200_spi_xfer()
224 ns->data_len = 0; in __atcspi200_spi_xfer()
225 ns->din = 0; in __atcspi200_spi_xfer()
226 ns->dout = 0; in __atcspi200_spi_xfer()
227 cmd_len = ns->cmd_len = data_len; in __atcspi200_spi_xfer()
231 __atcspi200_spi_start(ns); in __atcspi200_spi_xfer()
243 ns->tran_len = tran_len; in __atcspi200_spi_xfer()
248 __atcspi200_spi_start(ns); in __atcspi200_spi_xfer()
251 event = in_le32(&ns->regs->status); in __atcspi200_spi_xfer()
253 __nspi_espi_tx(ns, dout); in __atcspi200_spi_xfer()
267 if (__nspi_espi_rx(ns, din, rx_bytes) == rx_bytes) { in __atcspi200_spi_xfer()
277 ns->cmd_buf[1] += ((tran_len>>16)&0xff); in __atcspi200_spi_xfer()
278 ns->cmd_buf[2] += ((tran_len>>8)&0xff); in __atcspi200_spi_xfer()
279 ns->cmd_buf[3] += ((tran_len)&0xff); in __atcspi200_spi_xfer()
280 ns->data_len = data_len; in __atcspi200_spi_xfer()
282 ret = __atcspi200_spi_stop(ns); in __atcspi200_spi_xfer()
284 ret = __atcspi200_spi_stop(ns); in __atcspi200_spi_xfer()
291 struct nds_spi_slave *ns = dev_get_priv(bus); in atcspi200_spi_set_speed() local
295 ns->freq = max_hz; in atcspi200_spi_set_speed()
296 __atcspi200_spi_set_speed(ns); in atcspi200_spi_set_speed()
303 struct nds_spi_slave *ns = dev_get_priv(bus); in atcspi200_spi_set_mode() local
306 ns->mode = mode; in atcspi200_spi_set_mode()
316 struct nds_spi_slave *ns = dev_get_priv(bus); in atcspi200_spi_claim_bus() local
318 if (slave_plat->cs >= ns->num_cs) { in atcspi200_spi_claim_bus()
323 return __atcspi200_spi_claim_bus(ns); in atcspi200_spi_claim_bus()
328 struct nds_spi_slave *ns = dev_get_priv(dev->parent); in atcspi200_spi_release_bus() local
330 return __atcspi200_spi_release_bus(ns); in atcspi200_spi_release_bus()
338 struct nds_spi_slave *ns = dev_get_priv(bus); in atcspi200_spi_xfer() local
340 return __atcspi200_spi_xfer(ns, bitlen, dout, din, flags); in atcspi200_spi_xfer()
345 struct nds_spi_slave *ns = dev_get_priv(bus); in atcspi200_spi_get_clk() local
358 ns->clock = clk_rate; in atcspi200_spi_get_clk()
366 struct nds_spi_slave *ns = dev_get_priv(bus); in atcspi200_spi_probe() local
368 ns->to = SPI_TIMEOUT; in atcspi200_spi_probe()
369 ns->max_transfer_length = MAX_TRANSFER_LEN; in atcspi200_spi_probe()
370 ns->mtiming = ns->regs->timing; in atcspi200_spi_probe()
378 struct nds_spi_slave *ns = dev_get_priv(bus); in atcspi200_ofdata_to_platadata() local
382 ns->regs = map_physmem(dev_read_addr(bus), in atcspi200_ofdata_to_platadata()
385 if (!ns->regs) { in atcspi200_ofdata_to_platadata()
389 ns->num_cs = fdtdec_get_int(blob, node, "num-cs", 4); in atcspi200_ofdata_to_platadata()