| /* |
| * (C) Copyright 2010 |
| * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de |
| * |
| * SPDX-License-Identifier: GPL-2.0+ |
| */ |
| |
| #include <common.h> |
| #include <command.h> |
| #include <asm/processor.h> |
| #include <asm/io.h> |
| #include <asm/ppc4xx-gpio.h> |
| |
| #include "405ep.h" |
| #include <gdsys_fpga.h> |
| |
| #include "../common/osd.h" |
| |
| #define LATCH0_BASE (CONFIG_SYS_LATCH_BASE) |
| #define LATCH1_BASE (CONFIG_SYS_LATCH_BASE + 0x100) |
| #define LATCH2_BASE (CONFIG_SYS_LATCH_BASE + 0x200) |
| |
| enum { |
| UNITTYPE_MAIN_SERVER = 0, |
| UNITTYPE_MAIN_USER = 1, |
| UNITTYPE_VIDEO_SERVER = 2, |
| UNITTYPE_VIDEO_USER = 3, |
| }; |
| |
| enum { |
| HWVER_100 = 0, |
| HWVER_104 = 1, |
| HWVER_110 = 2, |
| }; |
| |
| enum { |
| COMPRESSION_NONE = 0, |
| COMPRESSION_TYPE1_DELTA, |
| }; |
| |
| enum { |
| AUDIO_NONE = 0, |
| AUDIO_TX = 1, |
| AUDIO_RX = 2, |
| AUDIO_RXTX = 3, |
| }; |
| |
| enum { |
| SYSCLK_147456 = 0, |
| }; |
| |
| enum { |
| RAM_DDR2_32 = 0, |
| }; |
| |
| struct ihs_fpga *fpga_ptr[] = CONFIG_SYS_FPGA_PTR; |
| |
| /* |
| * Check Board Identity: |
| */ |
| int checkboard(void) |
| { |
| char *s = getenv("serial#"); |
| |
| puts("Board: "); |
| |
| puts("IoCon"); |
| |
| if (s != NULL) { |
| puts(", serial# "); |
| puts(s); |
| } |
| |
| puts("\n"); |
| |
| return 0; |
| } |
| |
| static void print_fpga_info(void) |
| { |
| u16 versions; |
| u16 fpga_version; |
| u16 fpga_features; |
| unsigned unit_type; |
| unsigned hardware_version; |
| unsigned feature_compression; |
| unsigned feature_osd; |
| unsigned feature_audio; |
| unsigned feature_sysclock; |
| unsigned feature_ramconfig; |
| unsigned feature_carriers; |
| unsigned feature_video_channels; |
| |
| FPGA_GET_REG(0, versions, &versions); |
| FPGA_GET_REG(0, fpga_version, &fpga_version); |
| FPGA_GET_REG(0, fpga_features, &fpga_features); |
| |
| unit_type = (versions & 0xf000) >> 12; |
| hardware_version = versions & 0x000f; |
| feature_compression = (fpga_features & 0xe000) >> 13; |
| feature_osd = fpga_features & (1<<11); |
| feature_audio = (fpga_features & 0x0600) >> 9; |
| feature_sysclock = (fpga_features & 0x0180) >> 7; |
| feature_ramconfig = (fpga_features & 0x0060) >> 5; |
| feature_carriers = (fpga_features & 0x000c) >> 2; |
| feature_video_channels = fpga_features & 0x0003; |
| |
| switch (unit_type) { |
| case UNITTYPE_MAIN_USER: |
| printf("Mainchannel"); |
| break; |
| |
| case UNITTYPE_VIDEO_USER: |
| printf("Videochannel"); |
| break; |
| |
| default: |
| printf("UnitType %d(not supported)", unit_type); |
| break; |
| } |
| |
| switch (hardware_version) { |
| case HWVER_100: |
| printf(" HW-Ver 1.00\n"); |
| break; |
| |
| case HWVER_104: |
| printf(" HW-Ver 1.04\n"); |
| break; |
| |
| case HWVER_110: |
| printf(" HW-Ver 1.10\n"); |
| break; |
| |
| default: |
| printf(" HW-Ver %d(not supported)\n", |
| hardware_version); |
| break; |
| } |
| |
| printf(" FPGA V %d.%02d, features:", |
| fpga_version / 100, fpga_version % 100); |
| |
| |
| switch (feature_compression) { |
| case COMPRESSION_NONE: |
| printf(" no compression"); |
| break; |
| |
| case COMPRESSION_TYPE1_DELTA: |
| printf(" type1-deltacompression"); |
| break; |
| |
| default: |
| printf(" compression %d(not supported)", feature_compression); |
| break; |
| } |
| |
| printf(", %sosd", feature_osd ? "" : "no "); |
| |
| switch (feature_audio) { |
| case AUDIO_NONE: |
| printf(", no audio"); |
| break; |
| |
| case AUDIO_TX: |
| printf(", audio tx"); |
| break; |
| |
| case AUDIO_RX: |
| printf(", audio rx"); |
| break; |
| |
| case AUDIO_RXTX: |
| printf(", audio rx+tx"); |
| break; |
| |
| default: |
| printf(", audio %d(not supported)", feature_audio); |
| break; |
| } |
| |
| puts(",\n "); |
| |
| switch (feature_sysclock) { |
| case SYSCLK_147456: |
| printf("clock 147.456 MHz"); |
| break; |
| |
| default: |
| printf("clock %d(not supported)", feature_sysclock); |
| break; |
| } |
| |
| switch (feature_ramconfig) { |
| case RAM_DDR2_32: |
| printf(", RAM 32 bit DDR2"); |
| break; |
| |
| default: |
| printf(", RAM %d(not supported)", feature_ramconfig); |
| break; |
| } |
| |
| printf(", %d carrier(s)", feature_carriers); |
| |
| printf(", %d video channel(s)\n", feature_video_channels); |
| } |
| |
| int last_stage_init(void) |
| { |
| print_fpga_info(); |
| |
| return osd_probe(0); |
| } |
| |
| /* |
| * provide access to fpga gpios (for I2C bitbang) |
| * (these may look all too simple but make iocon.h much more readable) |
| */ |
| void fpga_gpio_set(int pin) |
| { |
| FPGA_SET_REG(0, gpio.set, pin); |
| } |
| |
| void fpga_gpio_clear(int pin) |
| { |
| FPGA_SET_REG(0, gpio.clear, pin); |
| } |
| |
| int fpga_gpio_get(int pin) |
| { |
| u16 val; |
| |
| FPGA_GET_REG(0, gpio.read, &val); |
| |
| return val & pin; |
| } |
| |
| void gd405ep_init(void) |
| { |
| } |
| |
| void gd405ep_set_fpga_reset(unsigned state) |
| { |
| if (state) { |
| out_le16((void *)LATCH0_BASE, CONFIG_SYS_LATCH0_RESET); |
| out_le16((void *)LATCH1_BASE, CONFIG_SYS_LATCH1_RESET); |
| } else { |
| out_le16((void *)LATCH0_BASE, CONFIG_SYS_LATCH0_BOOT); |
| out_le16((void *)LATCH1_BASE, CONFIG_SYS_LATCH1_BOOT); |
| } |
| } |
| |
| void gd405ep_setup_hw(void) |
| { |
| /* |
| * set "startup-finished"-gpios |
| */ |
| gpio_write_bit(21, 0); |
| gpio_write_bit(22, 1); |
| } |
| |
| int gd405ep_get_fpga_done(unsigned fpga) |
| { |
| return in_le16((void *)LATCH2_BASE) & CONFIG_SYS_FPGA_DONE(fpga); |
| } |