Commit aa42cb71fa28a4f2c8b8cc0e691151f4ba19dbd9

Authored by Shaveta Leekha
Committed by Andy Fleming
1 parent 379c5145ef

board/freescale/common: VSC3316/VSC3308 initialization code

Add code for configuring VSC3316/3308 crosspoint switches
Add README to understand the APIs

   - VSC 3316/3308 is a low-power, low-cost asynchronous crosspoint switch
     capable of data rates upto 11.5Gbps. VSC3316 has 16 input and 16
     output ports whereas VSC3308 has 8 input and 8 output ports.
     Programming of these devices are performed by two-wire or four-wire
     serial interface.

Signed-off-by: Shaveta Leekha <shaveta@freescale.com>
Signed-off-by: Andy Fleming <afleming@freescale.com>

Showing 4 changed files with 262 additions and 0 deletions Side-by-side Diff

board/freescale/common/Makefile
... ... @@ -53,6 +53,7 @@
53 53 COBJS-$(CONFIG_P3041DS) += ics307_clk.o
54 54 COBJS-$(CONFIG_P4080DS) += ics307_clk.o
55 55 COBJS-$(CONFIG_P5020DS) += ics307_clk.o
  56 +COBJS-$(CONFIG_VSC_CROSSBAR) += vsc3316_3308.o
56 57  
57 58 # deal with common files for P-series corenet based devices
58 59 SUBLIB-$(CONFIG_P2041RDB) += p_corenet/libp_corenet.o
board/freescale/common/vsc3316_3308.c
  1 +/*
  2 + * Copyright 2012 Freescale Semiconductor, Inc.
  3 + *
  4 + * See file CREDITS for list of people who contributed to this
  5 + * project.
  6 + *
  7 + * This program is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU General Public License as
  9 + * published by the Free Software Foundation; either version 2 of
  10 + * the License, or (at your option) any later version.
  11 + *
  12 + * This program is distributed in the hope that it will be useful,
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15 + * GNU General Public License for more details.
  16 + *
  17 + * You should have received a copy of the GNU General Public License
  18 + * along with this program; if not, write to the Free Software
  19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20 + * MA 02111-1307 USA
  21 + */
  22 +
  23 +#include "vsc3316_3308.h"
  24 +
  25 +#define REVISION_ID_REG 0x7E
  26 +#define INTERFACE_MODE_REG 0x79
  27 +#define CURRENT_PAGE_REGISTER 0x7F
  28 +#define CONNECTION_CONFIG_PAGE 0x00
  29 +#define INPUT_STATE_REG 0x13
  30 +#define GLOBAL_INPUT_ISE1 0x51
  31 +#define GLOBAL_INPUT_ISE2 0x52
  32 +#define GLOBAL_INPUT_LOS 0x55
  33 +#define GLOBAL_CORE_CNTRL 0x5D
  34 +#define OUTPUT_MODE_PAGE 0x23
  35 +#define CORE_CONTROL_PAGE 0x25
  36 +#define CORE_CONFIG_REG 0x75
  37 +
  38 +int vsc_if_enable(unsigned int vsc_addr)
  39 +{
  40 + u8 data;
  41 +
  42 + debug("VSC:Configuring VSC at I2C address 0x%2x"
  43 + " for 2-wire interface\n", vsc_addr);
  44 +
  45 + /* enable 2-wire Serial InterFace (I2C) */
  46 + data = 0x02;
  47 + return i2c_write(vsc_addr, INTERFACE_MODE_REG, 1, &data, 1);
  48 +}
  49 +
  50 +int vsc3316_config(unsigned int vsc_addr, const int8_t con_arr[][2],
  51 + unsigned int num_con)
  52 +{
  53 + unsigned int i;
  54 + u8 rev_id = 0;
  55 + int ret;
  56 +
  57 + debug("VSC:Initializing VSC3316 at I2C address 0x%2x"
  58 + " for Tx\n", vsc_addr);
  59 +
  60 + ret = i2c_read(vsc_addr, REVISION_ID_REG, 1, &rev_id, 1);
  61 + if (ret < 0) {
  62 + printf("VSC:0x%x could not read REV_ID from device.\n",
  63 + vsc_addr);
  64 + return ret;
  65 + }
  66 +
  67 + if (rev_id != 0xab) {
  68 + printf("VSC: device at address 0x%x is not VSC3316/3308.\n",
  69 + vsc_addr);
  70 + return -ENODEV;
  71 + }
  72 +
  73 + ret = vsc_if_enable(vsc_addr);
  74 + if (ret) {
  75 + printf("VSC:0x%x could not configured for 2-wire I/F.\n",
  76 + vsc_addr);
  77 + return ret;
  78 + }
  79 +
  80 + /* config connections - page 0x00 */
  81 + i2c_reg_write(vsc_addr, CURRENT_PAGE_REGISTER, CONNECTION_CONFIG_PAGE);
  82 +
  83 + /* Making crosspoint connections, by connecting required
  84 + * input to output */
  85 + for (i = 0; i < num_con ; i++)
  86 + i2c_reg_write(vsc_addr, con_arr[i][1], con_arr[i][0]);
  87 +
  88 + /* input state - page 0x13 */
  89 + i2c_reg_write(vsc_addr, CURRENT_PAGE_REGISTER, INPUT_STATE_REG);
  90 + /* Configuring the required input of the switch */
  91 + for (i = 0; i < num_con ; i++)
  92 + i2c_reg_write(vsc_addr, con_arr[i][0], 0x80);
  93 +
  94 + /* Setting Global Input LOS threshold value */
  95 + i2c_reg_write(vsc_addr, GLOBAL_INPUT_LOS, 0x60);
  96 +
  97 + /* config output mode - page 0x23 */
  98 + i2c_reg_write(vsc_addr, CURRENT_PAGE_REGISTER, OUTPUT_MODE_PAGE);
  99 + /* Turn ON the Output driver correspond to required output*/
  100 + for (i = 0; i < num_con ; i++)
  101 + i2c_reg_write(vsc_addr, con_arr[i][1], 0);
  102 +
  103 + /* configure global core control register, Turn on Global core power */
  104 + i2c_reg_write(vsc_addr, GLOBAL_CORE_CNTRL, 0);
  105 +
  106 + vsc_wp_config(vsc_addr);
  107 +
  108 + return 0;
  109 +}
  110 +
  111 +int vsc3308_config(unsigned int vsc_addr, const int8_t con_arr[][2],
  112 + unsigned int num_con)
  113 +{
  114 + unsigned int i;
  115 + u8 rev_id = 0;
  116 + int ret;
  117 +
  118 + debug("VSC:Initializing VSC3308 at I2C address 0x%x"
  119 + " for Tx\n", vsc_addr);
  120 +
  121 + ret = i2c_read(vsc_addr, REVISION_ID_REG, 1, &rev_id, 1);
  122 + if (ret < 0) {
  123 + printf("VSC:0x%x could not read REV_ID from device.\n",
  124 + vsc_addr);
  125 + return ret;
  126 + }
  127 +
  128 + if (rev_id != 0xab) {
  129 + printf("VSC: device at address 0x%x is not VSC3316/3308.\n",
  130 + vsc_addr);
  131 + return -ENODEV;
  132 + }
  133 +
  134 + ret = vsc_if_enable(vsc_addr);
  135 + if (ret) {
  136 + printf("VSC:0x%x could not configured for 2-wire I/F.\n",
  137 + vsc_addr);
  138 + return ret;
  139 + }
  140 +
  141 + /* config connections - page 0x00 */
  142 + i2c_reg_write(vsc_addr, CURRENT_PAGE_REGISTER, CONNECTION_CONFIG_PAGE);
  143 +
  144 + /* Making crosspoint connections, by connecting required
  145 + * input to output */
  146 + for (i = 0; i < num_con ; i++)
  147 + i2c_reg_write(vsc_addr, con_arr[i][1], con_arr[i][0]);
  148 +
  149 + /*Configure Global Input ISE and gain */
  150 + i2c_reg_write(vsc_addr, GLOBAL_INPUT_ISE1, 0x12);
  151 + i2c_reg_write(vsc_addr, GLOBAL_INPUT_ISE2, 0x12);
  152 +
  153 + /* input state - page 0x13 */
  154 + i2c_reg_write(vsc_addr, CURRENT_PAGE_REGISTER, INPUT_STATE_REG);
  155 + /* Turning ON the required input of the switch */
  156 + for (i = 0; i < num_con ; i++)
  157 + i2c_reg_write(vsc_addr, con_arr[i][0], 0);
  158 +
  159 + /* Setting Global Input LOS threshold value */
  160 + i2c_reg_write(vsc_addr, GLOBAL_INPUT_LOS, 0x60);
  161 +
  162 + /* config output mode - page 0x23 */
  163 + i2c_reg_write(vsc_addr, CURRENT_PAGE_REGISTER, OUTPUT_MODE_PAGE);
  164 + /* Turn ON the Output driver correspond to required output*/
  165 + for (i = 0; i < num_con ; i++)
  166 + i2c_reg_write(vsc_addr, con_arr[i][1], 0);
  167 +
  168 + /* configure global core control register, Turn on Global core power */
  169 + i2c_reg_write(vsc_addr, GLOBAL_CORE_CNTRL, 0);
  170 +
  171 + vsc_wp_config(vsc_addr);
  172 +
  173 + return 0;
  174 +}
  175 +
  176 +void vsc_wp_config(unsigned int vsc_addr)
  177 +{
  178 + debug("VSC:Configuring VSC at address:0x%x for WP\n", vsc_addr);
  179 +
  180 + /* For new crosspoint configuration to occur, WP bit of
  181 + * CORE_CONFIG_REG should be set 1 and then reset to 0 */
  182 + i2c_reg_write(vsc_addr, CORE_CONFIG_REG, 0x01);
  183 + i2c_reg_write(vsc_addr, CORE_CONFIG_REG, 0x0);
  184 +}
board/freescale/common/vsc3316_3308.h
  1 +/*
  2 + * Copyright 2012 Freescale Semiconductor, Inc.
  3 + *
  4 + * This program is free software; you can redistribute it and/or
  5 + * modify it under the terms of the GNU General Public License as
  6 + * published by the Free Software Foundation; either version 2 of
  7 + * the License, or (at your option) any later version.
  8 + *
  9 + * This program is distributed in the hope that it will be useful,
  10 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12 + * GNU General Public License for more details.
  13 + *
  14 + * You should have received a copy of the GNU General Public License
  15 + * along with this program; if not, write to the Free Software
  16 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  17 + * MA 02111-1307 USA
  18 + */
  19 +
  20 +#ifndef __VSC_CROSSBAR_H_
  21 +#define __VSC_CROSSBAR_H 1_
  22 +
  23 +#include <common.h>
  24 +#include <i2c.h>
  25 +#include <errno.h>
  26 +
  27 +int vsc_if_enable(unsigned int vsc_addr);
  28 +int vsc3316_config(unsigned int vsc_addr, const int8_t con_arr[][2],
  29 + unsigned int num_con);
  30 +int vsc3308_config(unsigned int vsc_addr, const int8_t con_arr[][2],
  31 + unsigned int num_con);
  32 +void vsc_wp_config(unsigned int vsc_addr);
  33 +
  34 +#endif /* __VSC_CROSSBAR_H_ */
doc/README.VSC3316-3308
  1 +This file contains API information of the initialization code written for
  2 +Vitesse cross-point devices, VSC3316 and VSC3308 for board B4860QDS
  3 +
  4 +Author: Shaveta Leekha <shaveta@freescale.com>
  5 +
  6 +About Device:
  7 +=============
  8 +VSC 3316/3308 is a low-power, low-cost asynchronous crosspoint switch capable of data rates upto 11.5Gbps.
  9 +
  10 +VSC3316 has 16 input and 16 output ports whereas VSC3308 has 8 input and 8 output ports. Programming of these devices are performed by two-wire or four-wire serial interface.
  11 +
  12 +Initialization:
  13 +===============
  14 +On reset, VSC devices are in low-power state with all inputs, outputs and connections in an off state.
  15 +First thing required is to program it to interface with either two-wire or four-wire interface.
  16 +In our case the interface is two-wire I2C serial interface. So the value in Interface mode register at address 79.h to be written is 0x02 for two-wire interface. Also for crosspoint connections to be activated, 01.h value need to be written in 75.h (core configuration register).
  17 +
  18 +API Overview:
  19 +=============
  20 +
  21 + vsc_if_enable(u8 vsc_addr):
  22 + --------------------------
  23 + This API programs VSC to interface with either two-wire or four-wire interface. In our case the interface is two-wire I2C serial interface. So the value in Interface mode register at address 79.h to be written is 0x02 for two-wire interface.
  24 + Parameters:
  25 + vsc_addr - Address of the VSC device on board.
  26 +
  27 +
  28 + vsc3316_config(u8 vsc_addr, int con_arr[][2], u8 num_con):
  29 + ---------------------------------------------------------
  30 + This API configures the VSC3316 device for required connections. Connection through the VSC device requires the inputs and outputs to be properly configured.
  31 + Connection registers are on page 00. It Configures the selected input and output correctly and join them to make a connection. It also program Input state register, Global input ISE, Global input LOS, Global core control, Output mode register and core control registers etc.
  32 + vsc3308_config(u8 vsc_addr, int con_arr[][2], u8 num_con) does the essential configurations for VSC3308.
  33 +
  34 + Parameters:
  35 + vsc_addr - Address of the VSC device on board.
  36 + con_arr - connection array
  37 + num_con - number of connections to be configured
  38 +
  39 + vsc_wp_config(u8 vsc_addr):
  40 + --------------------------
  41 + For crosspoint connections to be activated, 01.h value need to be written in 75.h (core configuration register), which is done by this API.
  42 + Parameters:
  43 + vsc_addr - Address of the VSC device on board.