Commit 7d861d95a315852532d581884b3b72536c25032c

Authored by Bob Liu
Committed by Sonic Zhang
1 parent e7b9aa96b1

blackfin: bf609: add softswitch config command

Add softswitch_output command for bf609-ezkit to enable softswitches.

Signed-off-by: Bob Liu <lliubbo@gmail.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>

Showing 7 changed files with 80 additions and 18 deletions Side-by-side Diff

... ... @@ -898,6 +898,7 @@
898 898 CONFIG_CMD_SF * Read/write/erase SPI NOR flash
899 899 CONFIG_CMD_SHA1SUM print sha1 memory digest
900 900 (requires CONFIG_CMD_MEMORY)
  901 + CONFIG_CMD_SOFTSWITCH * Soft switch setting command for BF60x
901 902 CONFIG_CMD_SOURCE "source" command Support
902 903 CONFIG_CMD_SPI * SPI serial bus support
903 904 CONFIG_CMD_TFTPSRV * TFTP transfer in server mode
arch/blackfin/include/asm/soft_switch.h
  1 +/*
  2 + * U-boot - main board file
  3 + *
  4 + * Copyright (c) 2008-2012 Analog Devices Inc.
  5 + *
  6 + * Licensed under the GPL-2 or later.
  7 + */
  8 +
  9 +#ifndef __SOFT_SWITCH_H__
  10 +#define __SOFT_SWITCH_H__
  11 +
  12 +#define IO_PORT_A 0
  13 +#define IO_PORT_B 1
  14 +#define IO_PORT_INPUT 0
  15 +#define IO_PORT_OUTPUT 1
  16 +
  17 +int config_switch_bit(int num, int port, int bit, int dir, uchar value);
  18 +#endif
board/bf609-ezkit/soft_switch.c
... ... @@ -12,14 +12,6 @@
12 12 #include <i2c.h>
13 13 #include "soft_switch.h"
14 14  
15   -#define SWITCH_ADDR 0x21
16   -
17   -#define NUM_SWITCH 3
18   -#define IODIRA 0x0
19   -#define IODIRB 0x1
20   -#define OLATA 0x14
21   -#define OLATB 0x15
22   -
23 15 struct switch_config {
24 16 uchar dir0; /* IODIRA */
25 17 uchar dir1; /* IODIRB */
26 18  
... ... @@ -126,9 +118,8 @@
126 118 return i2c_write(addr, IODIRB, 1, &config->dir1, 1);
127 119 }
128 120  
129   -int config_switch_bit(int num, int port, int bit, int dir, uchar value)
  121 +int config_switch_bit(int addr, int port, int bit, int dir, uchar value)
130 122 {
131   - int addr = SWITCH_ADDR + num;
132 123 int ret, data_reg, dir_reg;
133 124 uchar tmp;
134 125  
board/bf609-ezkit/soft_switch.h
... ... @@ -6,9 +6,11 @@
6 6 * Licensed under the GPL-2 or later.
7 7 */
8 8  
9   -#ifndef __SOFT_SWITCH_H__
10   -#define __SOFT_SWITCH_H__
  9 +#ifndef __BOARD_SOFT_SWITCH_H__
  10 +#define __BOARD_SOFT_SWITCH_H__
11 11  
  12 +#include <asm/soft_switch.h>
  13 +
12 14 /* switch 0 port A */
13 15 #define CAN_EN 0x1
14 16 #define CAN_STB 0x2
15 17  
16 18  
... ... @@ -61,12 +63,19 @@
61 63 #define PD3_SPI0MOSI_EN 0x1
62 64 #define PD4_SPI0CK_EN 0x2
63 65  
64   -#define IO_PORT_A 0
65   -#define IO_PORT_B 1
66   -#define IO_PORT_INPUT 0
67   -#define IO_PORT_OUTPUT 1
  66 +#ifdef CONFIG_BFIN_BOARD_VERSION_1_0
  67 +#define SWITCH_ADDR 0x21
  68 +#else
  69 +#define SWITCH_ADDR 0x20
  70 +#endif
68 71  
69   -int config_switch_bit(int num, int port, int bit, int dir, uchar value);
  72 +#define NUM_SWITCH 3
  73 +#define IODIRA 0x0
  74 +#define IODIRB 0x1
  75 +#define OLATA 0x14
  76 +#define OLATB 0x15
  77 +
70 78 int setup_board_switches(void);
71   -#endif
  79 +
  80 +#endif /* __BOARD_SOFT_SWITCH_H__ */
... ... @@ -164,6 +164,7 @@
164 164 COBJS-$(CONFIG_CMD_SCSI) += cmd_scsi.o
165 165 COBJS-$(CONFIG_CMD_SHA1SUM) += cmd_sha1sum.o
166 166 COBJS-$(CONFIG_CMD_SETEXPR) += cmd_setexpr.o
  167 +COBJS-$(CONFIG_CMD_SOFTSWITCH) += cmd_softswitch.o
167 168 COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o
168 169 COBJS-$(CONFIG_CMD_SPIBOOTLDR) += cmd_spibootldr.o
169 170 COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o
common/cmd_softswitch.c
  1 +/*
  2 + * cmd_softswitch.c - set the softswitch for bf60x
  3 + *
  4 + * Copyright (c) 2012 Analog Devices Inc.
  5 + *
  6 + * Licensed under the GPL-2 or later.
  7 + */
  8 +
  9 +#include <common.h>
  10 +#include <command.h>
  11 +#include <asm/blackfin.h>
  12 +#include <asm/soft_switch.h>
  13 +
  14 +int do_softswitch(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  15 +{
  16 + int switchaddr, value, pin, port;
  17 +
  18 + if (argc != 5)
  19 + return CMD_RET_USAGE;
  20 +
  21 + if (strcmp(argv[2], "GPA") == 0)
  22 + port = IO_PORT_A;
  23 + else if (strcmp(argv[2], "GPB") == 0)
  24 + port = IO_PORT_B;
  25 + else
  26 + return CMD_RET_USAGE;
  27 +
  28 + switchaddr = simple_strtoul(argv[1], NULL, 16);
  29 + pin = simple_strtoul(argv[3], NULL, 16);
  30 + value = simple_strtoul(argv[4], NULL, 16);
  31 +
  32 + config_switch_bit(switchaddr, port, (1 << pin), IO_PORT_OUTPUT, value);
  33 +
  34 + return 0;
  35 +}
  36 +
  37 +U_BOOT_CMD(
  38 + softswitch_output, 5, 1, do_softswitch,
  39 + "switchaddr GPA/GPB pin_offset value",
  40 + ""
  41 +);
include/configs/bf609-ezkit.h
... ... @@ -144,6 +144,7 @@
144 144 #define CONFIG_UART_CONSOLE 0
145 145  
146 146 #define CONFIG_CMD_MEMORY
  147 +#define CONFIG_CMD_SOFTSWITCH
147 148  
148 149 #define CONFIG_SYS_MEMTEST_END (CONFIG_STACKBASE - 20*1024*1024 + 4)
149 150 #define CONFIG_BFIN_SOFT_SWITCH