phy: Use _nodev naming convention if non-device clients
[oweals/u-boot.git] / drivers / spi / sh_spi.c
index 744afe3295aebeca01ad9e1921ce387c0c823dbb..c58fd0ebc43812c8d5f64dc828fa4accf2bc42ac 100644 (file)
@@ -1,24 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * SH SPI driver
  *
  * Copyright (C) 2011-2012 Renesas Solutions Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
  */
 
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <spi.h>
 #include <asm/io.h>
@@ -78,10 +66,6 @@ static int write_fifo_empty_wait(struct sh_spi *ss)
        return 0;
 }
 
-void spi_init(void)
-{
-}
-
 static void sh_spi_set_cs(struct sh_spi *ss, unsigned int cs)
 {
        unsigned long val = 0;
@@ -151,7 +135,6 @@ static int sh_spi_send(struct sh_spi *ss, const unsigned char *tx_data,
 {
        int i, cur_len, ret = 0;
        int remain = (int)len;
-       unsigned long tmp;
 
        if (len >= SH_SPI_FIFO_SIZE)
                sh_spi_set_bit(SH_SPI_SSA, &ss->regs->cr1);
@@ -183,9 +166,7 @@ static int sh_spi_send(struct sh_spi *ss, const unsigned char *tx_data,
        }
 
        if (flags & SPI_XFER_END) {
-               tmp = sh_spi_read(&ss->regs->cr1);
-               tmp = tmp & ~(SH_SPI_SSD | SH_SPI_SSDB);
-               sh_spi_write(tmp, &ss->regs->cr1);
+               sh_spi_clear_bit(SH_SPI_SSD | SH_SPI_SSDB, &ss->regs->cr1);
                sh_spi_set_bit(SH_SPI_SSA, &ss->regs->cr1);
                udelay(100);
                write_fifo_empty_wait(ss);
@@ -198,16 +179,13 @@ static int sh_spi_receive(struct sh_spi *ss, unsigned char *rx_data,
                          unsigned int len, unsigned long flags)
 {
        int i;
-       unsigned long tmp;
 
        if (len > SH_SPI_MAX_BYTE)
                sh_spi_write(SH_SPI_MAX_BYTE, &ss->regs->cr3);
        else
                sh_spi_write(len, &ss->regs->cr3);
 
-       tmp = sh_spi_read(&ss->regs->cr1);
-       tmp = tmp & ~(SH_SPI_SSD | SH_SPI_SSDB);
-       sh_spi_write(tmp, &ss->regs->cr1);
+       sh_spi_clear_bit(SH_SPI_SSD | SH_SPI_SSDB, &ss->regs->cr1);
        sh_spi_set_bit(SH_SPI_SSA, &ss->regs->cr1);
 
        for (i = 0; i < len; i++) {