]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - drivers/misc/ds4510.c
Kconfig: Drop CONFIG_CMD_DS4510
[people/ms/u-boot.git] / drivers / misc / ds4510.c
index 5b33c1ffcedda0cff658be4b15c26f99568eb3cf..9ffdafc9929d657e097f8e19dedc078ea61bbb60 100644 (file)
@@ -1,19 +1,7 @@
 /*
  * Copyright 2008 Extreme Engineering Solutions, Inc.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * Version 2 as published by the Free Software Foundation.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0
  */
 
 /*
@@ -24,7 +12,7 @@
 #include <common.h>
 #include <i2c.h>
 #include <command.h>
-#include <ds4510.h>
+#include "ds4510.h"
 
 /* Default to an address that hopefully won't corrupt other i2c devices */
 #ifndef CONFIG_SYS_I2C_DS4510_ADDR
@@ -47,7 +35,7 @@ enum {
 /*
  * Write to DS4510, taking page boundaries into account
  */
-int ds4510_mem_write(uint8_t chip, int offset, uint8_t *buf, int count)
+static int ds4510_mem_write(uint8_t chip, int offset, uint8_t *buf, int count)
 {
        int wrlen;
        int i = 0;
@@ -76,7 +64,7 @@ int ds4510_mem_write(uint8_t chip, int offset, uint8_t *buf, int count)
 /*
  * General read from DS4510
  */
-int ds4510_mem_read(uint8_t chip, int offset, uint8_t *buf, int count)
+static int ds4510_mem_read(uint8_t chip, int offset, uint8_t *buf, int count)
 {
        return i2c_read(chip, offset, 1, buf, count);
 }
@@ -86,7 +74,7 @@ int ds4510_mem_read(uint8_t chip, int offset, uint8_t *buf, int count)
  * nv = 0 - Writes to SEEPROM registers behave like EEPROM
  * nv = 1 - Writes to SEEPROM registers behave like SRAM
  */
-int ds4510_see_write(uint8_t chip, uint8_t nv)
+static int ds4510_see_write(uint8_t chip, uint8_t nv)
 {
        uint8_t data;
 
@@ -104,7 +92,7 @@ int ds4510_see_write(uint8_t chip, uint8_t nv)
 /*
  * Write de-assertion of reset signal delay
  */
-int ds4510_rstdelay_write(uint8_t chip, uint8_t delay)
+static int ds4510_rstdelay_write(uint8_t chip, uint8_t delay)
 {
        uint8_t data;
 
@@ -120,7 +108,7 @@ int ds4510_rstdelay_write(uint8_t chip, uint8_t delay)
 /*
  * Write pullup characteristics of IO pins
  */
-int ds4510_pullup_write(uint8_t chip, uint8_t val)
+static int ds4510_pullup_write(uint8_t chip, uint8_t val)
 {
        val &= DS4510_IO_MASK;
 
@@ -130,7 +118,7 @@ int ds4510_pullup_write(uint8_t chip, uint8_t val)
 /*
  * Read pullup characteristics of IO pins
  */
-int ds4510_pullup_read(uint8_t chip)
+static int ds4510_pullup_read(uint8_t chip)
 {
        uint8_t val;
 
@@ -143,7 +131,7 @@ int ds4510_pullup_read(uint8_t chip)
 /*
  * Write drive level of IO pins
  */
-int ds4510_gpio_write(uint8_t chip, uint8_t val)
+static int ds4510_gpio_write(uint8_t chip, uint8_t val)
 {
        uint8_t data;
        int i;
@@ -167,7 +155,7 @@ int ds4510_gpio_write(uint8_t chip, uint8_t val)
 /*
  * Read drive level of IO pins
  */
-int ds4510_gpio_read(uint8_t chip)
+static int ds4510_gpio_read(uint8_t chip)
 {
        uint8_t data;
        int val = 0;
@@ -187,7 +175,7 @@ int ds4510_gpio_read(uint8_t chip)
 /*
  * Read physical level of IO pins
  */
-int ds4510_gpio_read_val(uint8_t chip)
+static int ds4510_gpio_read_val(uint8_t chip)
 {
        uint8_t val;
 
@@ -197,8 +185,6 @@ int ds4510_gpio_read_val(uint8_t chip)
        return val & DS4510_IO_MASK;
 }
 
-#ifdef CONFIG_CMD_DS4510
-#ifdef CONFIG_CMD_DS4510_INFO
 /*
  * Display DS4510 information
  */
@@ -252,7 +238,6 @@ static int ds4510_info(uint8_t chip)
 
        return 0;
 }
-#endif /* CONFIG_CMD_DS4510_INFO */
 
 cmd_tbl_t cmd_ds4510[] = {
        U_BOOT_CMD_MKENT(device, 3, 0, (void *)DS4510_CMD_DEVICE, "", ""),
@@ -260,17 +245,11 @@ cmd_tbl_t cmd_ds4510[] = {
        U_BOOT_CMD_MKENT(output, 4, 0, (void *)DS4510_CMD_OUTPUT, "", ""),
        U_BOOT_CMD_MKENT(input, 3, 0, (void *)DS4510_CMD_INPUT, "", ""),
        U_BOOT_CMD_MKENT(pullup, 4, 0, (void *)DS4510_CMD_PULLUP, "", ""),
-#ifdef CONFIG_CMD_DS4510_INFO
        U_BOOT_CMD_MKENT(info, 2, 0, (void *)DS4510_CMD_INFO, "", ""),
-#endif
-#ifdef CONFIG_CMD_DS4510_RST
        U_BOOT_CMD_MKENT(rstdelay, 3, 0, (void *)DS4510_CMD_RSTDELAY, "", ""),
-#endif
-#ifdef CONFIG_CMD_DS4510_MEM
        U_BOOT_CMD_MKENT(eeprom, 6, 0, (void *)DS4510_CMD_EEPROM, "", ""),
        U_BOOT_CMD_MKENT(seeprom, 6, 0, (void *)DS4510_CMD_SEEPROM, "", ""),
        U_BOOT_CMD_MKENT(sram, 6, 0, (void *)DS4510_CMD_SRAM, "", ""),
-#endif
 };
 
 int do_ds4510(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
@@ -280,13 +259,11 @@ int do_ds4510(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        ulong ul_arg2 = 0;
        ulong ul_arg3 = 0;
        int tmp;
-#ifdef CONFIG_CMD_DS4510_MEM
        ulong addr;
        ulong off;
        ulong cnt;
        int end;
        int (*rw_func)(uint8_t, int, uint8_t *, int);
-#endif
 
        c = find_cmd_tbl(argv[1], cmd_ds4510, ARRAY_SIZE(cmd_ds4510));
 
@@ -294,8 +271,7 @@ int do_ds4510(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        if (!c || !((argc == (c->maxargs)) ||
                (((int)c->cmd == DS4510_CMD_DEVICE) &&
                 (argc == (c->maxargs - 1))))) {
-               cmd_usage(cmdtp);
-               return 1;
+               return cmd_usage(cmdtp);
        }
 
        /* arg2 used as chip addr and pin number */
@@ -337,15 +313,10 @@ int do_ds4510(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                else
                        tmp &= ~(1 << ul_arg2);
                return ds4510_pullup_write(chip, tmp);
-#ifdef CONFIG_CMD_DS4510_INFO
        case DS4510_CMD_INFO:
                return ds4510_info(chip);
-#endif
-#ifdef CONFIG_CMD_DS4510_RST
        case DS4510_CMD_RSTDELAY:
                return ds4510_rstdelay_write(chip, ul_arg2);
-#endif
-#ifdef CONFIG_CMD_DS4510_MEM
        case DS4510_CMD_EEPROM:
                end = DS4510_EEPROM + DS4510_EEPROM_SIZE;
                off = DS4510_EEPROM;
@@ -358,22 +329,18 @@ int do_ds4510(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                end = DS4510_SRAM + DS4510_SRAM_SIZE;
                off = DS4510_SRAM;
                break;
-#endif
        default:
                /* We should never get here... */
                return 1;
        }
 
-#ifdef CONFIG_CMD_DS4510_MEM
        /* Only eeprom, seeprom, and sram commands should make it here */
-       if (strcmp(argv[2], "read") == 0) {
+       if (strcmp(argv[2], "read") == 0)
                rw_func = ds4510_mem_read;
-       } else if (strcmp(argv[2], "write") == 0) {
+       else if (strcmp(argv[2], "write") == 0)
                rw_func = ds4510_mem_write;
-       } else {
-               cmd_usage(cmdtp);
-               return 1;
-       }
+       else
+               return cmd_usage(cmdtp);
 
        addr = simple_strtoul(argv[3], NULL, 16);
        off += simple_strtoul(argv[4], NULL, 16);
@@ -385,7 +352,6 @@ int do_ds4510(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        }
 
        return rw_func(chip, off, (uint8_t *)addr, cnt);
-#endif
 }
 
 U_BOOT_CMD(
@@ -393,10 +359,8 @@ U_BOOT_CMD(
        "ds4510 eeprom/seeprom/sram/gpio access",
        "device [dev]\n"
        "       - show or set current device address\n"
-#ifdef CONFIG_CMD_DS4510_INFO
        "ds4510 info\n"
        "       - display ds4510 info\n"
-#endif
        "ds4510 output pin 0|1\n"
        "       - set pin low or high-Z\n"
        "ds4510 input pin\n"
@@ -405,12 +369,9 @@ U_BOOT_CMD(
        "       - disable/enable pullup on specified pin\n"
        "ds4510 nv 0|1\n"
        "       - make gpio and seeprom writes volatile/non-volatile"
-#ifdef CONFIG_CMD_DS4510_RST
        "\n"
        "ds4510 rstdelay 0-3\n"
        "       - set reset output delay"
-#endif
-#ifdef CONFIG_CMD_DS4510_MEM
        "\n"
        "ds4510 eeprom read addr off cnt\n"
        "ds4510 eeprom write addr off cnt\n"
@@ -421,6 +382,4 @@ U_BOOT_CMD(
        "ds4510 sram read addr off cnt\n"
        "ds4510 sram write addr off cnt\n"
        "       - read/write 'cnt' bytes at SRAM offset 'off'"
-#endif
 );
-#endif /* CONFIG_CMD_DS4510 */