Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: timvideos/HDMI2USB-litex-firmware
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e050caa950bb
Choose a base ref
...
head repository: timvideos/HDMI2USB-litex-firmware
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2d1947034bc0
Choose a head ref
  • 16 commits
  • 20 files changed
  • 2 contributors

Commits on Dec 3, 2017

  1. Make -j based on nprocs.

    mithro committed Dec 3, 2017
    Copy the full SHA
    ed74410 View commit details
  2. Copy the full SHA
    946d8c2 View commit details
  3. travis: Override JOBS value.

    mithro committed Dec 3, 2017
    Copy the full SHA
    5eb1aaf View commit details
  4. Copy the full SHA
    62169b9 View commit details
  5. Copy the full SHA
    a39de3e View commit details

Commits on Dec 27, 2017

  1. Fixing the MMCM defines.

    mithro committed Dec 27, 2017
    Copy the full SHA
    cb3437d View commit details
  2. Updating submodules.

     * litex changed from v0.1-189-g56ef2290 to v0.1-213-g9adcc3a8
    
    Full submodule status
    --
     f56f329ed23a25d002352dedba1e8f092a47286f edid-decode (heads/master)
     070d8b29acf1445c08ebf3073d04206461819bbe flash_proxies (heads/master)
     f31f8a03ff6911befa6d07bf347f8478c30448d8 litedram (heads/master)
     937c2407276371d9f8c1bb19c4ae8e97e581da83 liteeth (heads/master)
     c836c467b8d086c7ade23a45557644e4620a4bdc litepcie (heads/master)
     c3d491552cc77312bbadf6488c08e1e3df9612ef litesata (heads/master)
     d5887a3eb0de105cfc55e52fbeb9de9da035e7db litescope (heads/master)
     7a17876bc7f8943a2a0b500e4c1cb1e454c680b6 liteusb (heads/master)
     cd44e3f14cd3042a948170d43c21919b00c3c35d litevideo (heads/master)
     9adcc3a8b99862cccf6ee6d07190b6a7f3c735de litex (v0.1-213-g9adcc3a8)
    mithro committed Dec 27, 2017
    Copy the full SHA
    5347fb8 View commit details
  3. Copy the full SHA
    e19fb1f View commit details

Commits on Dec 29, 2017

  1. tests: Fixing the common bits.

    mithro committed Dec 29, 2017
    Copy the full SHA
    f223ebf View commit details
  2. scripts: Skip linux

    mithro committed Dec 29, 2017
    Copy the full SHA
    77cadc0 View commit details
  3. Updating submodules.

     * litedram changed from f31f8a0 to a09b7a0
     * liteeth changed from 937c240 to ccdb85b
     * litepcie changed from c836c46 to 09dbd6d
     * litesata changed from c3d4915 to a8bf0d4
     * litescope changed from d5887a3 to 7757727
     * liteusb changed from 7a17876 to 9a78586
     * litevideo changed from cd44e3f to c9770cc
     * litex changed from v0.1-213-g9adcc3a8 to v0.1-217-g0a2d38ec
    
    Full submodule status
    --
     f56f329ed23a25d002352dedba1e8f092a47286f edid-decode (heads/master)
     070d8b29acf1445c08ebf3073d04206461819bbe flash_proxies (heads/master)
     a09b7a05b89af317c885b3939e2f13925cb8d95d litedram (remotes/origin/HEAD)
     ccdb85bcb7c6504d49cf8fabfc6fd5ff179c72c2 liteeth (remotes/origin/HEAD)
     09dbd6dd3053cc42baa7090ee042cb314853a7fc litepcie (remotes/origin/HEAD)
     a8bf0d42b22a5f355a629aad7392c59029164d67 litesata (remotes/origin/HEAD)
     7757727f5b9fe4cb4979897fa0aab934b4af6e88 litescope (remotes/origin/HEAD)
     9a78586e5e523843834f80826f387ff828012ff7 liteusb (remotes/origin/HEAD)
     c9770cc2da2df70c941376e9b937a2980822c739 litevideo (remotes/origin/HEAD)
     0a2d38ecd2e07fbb7e087631f3db552d178add77 litex (v0.1-217-g0a2d38ec)
    mithro committed Dec 29, 2017
    Copy the full SHA
    f660fd9 View commit details
  4. Update the merge script.

    mithro committed Dec 29, 2017
    Copy the full SHA
    03e92fe View commit details

Commits on Dec 30, 2017

  1. Merge pull request #382 from mithro/master

    Updating submodules.
    mithro authored Dec 30, 2017

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b6c1b0a View commit details
  2. Merge pull request #377 from mithro/not-parallel

    Better parallel make support
    mithro authored Dec 30, 2017

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b06327a View commit details
  3. Copy the full SHA
    45fb7a7 View commit details
  4. Copy the full SHA
    2d19470 View commit details
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -25,6 +25,9 @@ env:
global:
- HDMI2USB_UDEV_IGNORE=1
- CLEAN_CHECK=1
# Travis reports incorrect the hosts number of processors, override to 2
# cores.
- JOBS=2

install:
- export CPU="$C"
24 changes: 19 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -35,6 +35,13 @@ FIRMWARE ?= firmware
CLANG = 0
export CLANG

JOBS ?= $(shell nproc)
JOBS ?= 2

ifeq ($(shell [ $(JOBS) -gt 1 ] && echo true),true)
export MAKEFLAGS="-j $(JOBS) -l $(JOBS)"
endif

ifeq ($(PLATFORM_EXPANSION),)
FULL_PLATFORM = $(PLATFORM)
else
@@ -82,7 +89,6 @@ build/cache.mk: targets/*/*.py scripts/makefile-cache.sh

TARGETS=$(TARGETS_$(PLATFORM))


# Initialize submodules automatically
third_party/%/.git: .gitmodules
git submodule sync --recursive -- $$(dirname $@)
@@ -121,6 +127,7 @@ image-flash-py: image
$(PYTHON) flash.py --mode=image

.PHONY: image image-load image-flash image-flash-py image-flash-$(PLATFORM) image-load-$(PLATFORM)
.NOTPARALLEL: image-load image-flash image-flash-py image-flash-$(PLATFORM) image-load-$(PLATFORM)

# Gateware - the stuff which configures the FPGA.
# --------------------------------------
@@ -160,6 +167,7 @@ gateware-clean:
rm -rf $(TARGET_BUILD_DIR)/gateware

.PHONY: gateware gateware-load gateware-flash gateware-flash-py gateware-clean gateware-load-$(PLATFORM) gateware-flash-$(PLATFORM)
.NOTPARALLEL: gateware-load gateware-flash gateware-flash-py gateware-flash-$(PLATFORM) gateware-load-$(PLATFORM)

# Firmware - the stuff which runs in the soft CPU inside the FPGA.
# --------------------------------------
@@ -196,15 +204,16 @@ firmware-connect: firmware-connect-$(PLATFORM)
firmware-clear: firmware-clear-$(PLATFORM)
@true

.PHONY: firmware-load-$(PLATFORM) firmware-flash-$(PLATFORM) firmware-connect-$(PLATFORM) firmware-clear-$(PLATFORM)

firmware-clean:
rm -rf $(TARGET_BUILD_DIR)/software

firmware-test:
firmware/test.sh
scripts/check-firmware-newlines.sh

.PHONY: firmware-load-$(PLATFORM) firmware-flash-$(PLATFORM) firmware-flash-py firmware-connect-$(PLATFORM) firmware-clear-$(PLATFORM)
.NOTPARALLEL: firmware-load-$(PLATFORM) firmware-flash-$(PLATFORM) firmware-flash-py firmware-connect-$(PLATFORM) firmware-clear-$(PLATFORM)
.PHONY: firmware-cmd $(FIRMWARE_FILEBASE).bin firmware firmware-load firmware-flash firmware-connect firmware-clean firmware-test
.NOTPARALLEL: firmware-cmd firmware-load firmware-flash firmware-connect

$(BIOS_FILE): firmware-cmd
@true
@@ -216,6 +225,7 @@ bios-flash: $(BIOS_FILE) bios-flash-$(PLATFORM)
@true

.PHONY: $(FIRMWARE_FILE) bios bios-flash bios-flash-$(PLATFORM)
.NOTPARALLEL: bios-flash bios-flash-$(PLATFORM)


# TFTP booting stuff
@@ -244,6 +254,7 @@ tftpd_start:
fi

.PHONY: tftp tftpd_stop tftpd_start
.NOTPARALLEL: tftp tftpd_stop tftpd_start

# Extra targets
# --------------------------------------
@@ -267,6 +278,7 @@ env:
@# Hardcoded values
@echo "export CLANG=$(CLANG)"
@echo "export PYTHONHASHSEED=$(PYTHONHASHSEED)"
@echo "export JOBS=$(JOBS)"
@# Files
@echo "export IMAGE_FILE='$(IMAGE_FILE)'"
@echo "export GATEWARE_FILEBASE='$(GATEWARE_FILEBASE)'"
@@ -364,7 +376,8 @@ clean:
dist-clean:
rm -rf build

.PHONY: flash help clean dist-clean help-$(PLATFORM) reset reset-$(PLATFORM)
.PHONY: flash env info prompt help clean dist-clean help-$(PLATFORM) reset reset-$(PLATFORM)
.NOTPARALLEL: flash env prompt info help help-$(PLATFORM) reset reset-$(PLATFORM)

# Tests
# --------------------------------------
@@ -379,3 +392,4 @@ test: firmware-test
@echo "Tests passed"

.PHONY: test test-edid
.NOTPARALLEL: test test-edid
2 changes: 1 addition & 1 deletion firmware/ci.c
Original file line number Diff line number Diff line change
@@ -940,7 +940,7 @@ static void debug_clocks(void)
{
// Only the active clock system will output anything
pll_dump();
mmcm_dump();
mmcm_dump_all();
}

static unsigned int log2(unsigned int v)
96 changes: 59 additions & 37 deletions firmware/mmcm.c
Original file line number Diff line number Diff line change
@@ -8,92 +8,114 @@
* Despite varying pixel clocks, we must keep the PLL VCO operating
* in the specified range of 600MHz - 1200MHz.
*/
#ifdef CSR_HDMI_OUT0_CLOCKING_MMCM_RESET_ADDR
void hdmi_out0_mmcm_write(int adr, int data) {
#ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR
void hdmi_out0_driver_clocking_mmcm_write(int adr, int data)
{
hdmi_out0_driver_clocking_mmcm_adr_write(adr);
hdmi_out0_driver_clocking_mmcm_dat_w_write(data);
hdmi_out0_driver_clocking_mmcm_write_write(1);
while(!hdmi_out0_driver_clocking_mmcm_drdy_read());
}

int hdmi_out0_mmcm_read(int adr) {
int hdmi_out0_driver_clocking_mmcm_read(int adr)
{
hdmi_out0_driver_clocking_mmcm_adr_write(adr);
hdmi_out0_driver_clocking_mmcm_read_write(1);
while(!hdmi_out0_driver_clocking_mmcm_drdy_read());
return hdmi_out0_driver_clocking_mmcm_dat_r_read();
}

MMCM hdmi_out0_driver_clocking_mmcm = {
.write = &hdmi_out0_driver_clocking_mmcm_write,
.read = &hdmi_out0_driver_clocking_mmcm_read,
};
#endif

#ifdef CSR_HDMI_IN0_CLOCKING_MMCM_RESET_ADDR
void hdmi_in0_clocking_mmcm_write(int adr, int data) {
void hdmi_in0_clocking_mmcm_write(int adr, int data)
{
hdmi_in0_clocking_mmcm_adr_write(adr);
hdmi_in0_clocking_mmcm_dat_w_write(data);
hdmi_in0_clocking_mmcm_write_write(1);
while(!hdmi_in0_clocking_mmcm_drdy_read());
}

int hdmi_in0_clocking_mmcm_read(int adr) {
int hdmi_in0_clocking_mmcm_read(int adr)
{
hdmi_in0_clocking_mmcm_adr_write(adr);
hdmi_in0_clocking_mmcm_read_write(1);
while(!hdmi_in0_clocking_mmcm_drdy_read());
return hdmi_in0_clocking_mmcm_dat_r_read();
}

static void hdmi_in_0_config_30_60mhz(void) {
hdmi_in0_clocking_mmcm_write(0x14, 0x1000 | (10<<6) | 10); /* clkfbout_mult = 20 */
hdmi_in0_clocking_mmcm_write(0x08, 0x1000 | (10<<6) | 10); /* clkout0_divide = 20 */
hdmi_in0_clocking_mmcm_write(0x0a, 0x1000 | (8<<6) | 8); /* clkout1_divide = 16 */
hdmi_in0_clocking_mmcm_write(0x0c, 0x1000 | (2<<6) | 2); /* clkout2_divide = 4 */
hdmi_in0_clocking_mmcm_write(0x0d, 0); /* clkout2_divide = 4 */
MMCM hdmi_in0_clocking_mmcm = {
.write = &hdmi_in0_clocking_mmcm_write,
.read = &hdmi_in0_clocking_mmcm_read,
};
#endif

static void mmcm_config_30to60mhz(MMCM *mmcm)
{
mmcm->write(0x14, 0x1000 | (10<<6) | 10); /* clkfbout_mult = 20 */
mmcm->write(0x08, 0x1000 | (10<<6) | 10); /* clkout0_divide = 20 */
mmcm->write(0x0a, 0x1000 | (8<<6) | 8); /* clkout1_divide = 16 */
mmcm->write(0x0c, 0x1000 | (2<<6) | 2); /* clkout2_divide = 4 */
mmcm->write(0x0d, 0); /* clkout2_divide = 4 */
}

static void hdmi_in_0_config_60_120mhz(void) {
hdmi_in0_clocking_mmcm_write(0x14, 0x1000 | (5<<6) | 5); /* clkfbout_mult = 10 */
hdmi_in0_clocking_mmcm_write(0x08, 0x1000 | (5<<6) | 5); /* clkout0_divide = 10 */
hdmi_in0_clocking_mmcm_write(0x0a, 0x1000 | (4<<6) | 4); /* clkout1_divide = 8 */
hdmi_in0_clocking_mmcm_write(0x0c, 0x1000 | (1<<6) | 1); /* clkout2_divide = 2 */
hdmi_in0_clocking_mmcm_write(0x0d, 0); /* clkout2_divide = 2 */
static void mmcm_config_60to120mhz(MMCM *mmcm)
{
mmcm->write(0x14, 0x1000 | (5<<6) | 5); /* clkfbout_mult = 10 */
mmcm->write(0x08, 0x1000 | (5<<6) | 5); /* clkout0_divide = 10 */
mmcm->write(0x0a, 0x1000 | (4<<6) | 4); /* clkout1_divide = 8 */
mmcm->write(0x0c, 0x1000 | (1<<6) | 1); /* clkout2_divide = 2 */
mmcm->write(0x0d, 0); /* clkout2_divide = 2 */
}

static void hdmi_in_0_config_120_240mhz(void) {
hdmi_in0_clocking_mmcm_write(0x14, 0x1000 | (2<<6) | 3); /* clkfbout_mult = 5 */
hdmi_in0_clocking_mmcm_write(0x08, 0x1000 | (2<<6) | 3); /* clkout0_divide = 5 */
hdmi_in0_clocking_mmcm_write(0x0a, 0x1000 | (2<<6) | 2); /* clkout1_divide = 4 */
hdmi_in0_clocking_mmcm_write(0x0c, 0x1000 | (0<<6) | 0); /* clkout2_divide = 1 */
hdmi_in0_clocking_mmcm_write(0x0d, (1<<6)); /* clkout2_divide = 1 */
static void mmcm_config_120to240mhz(MMCM *mmcm)
{
mmcm->write(0x14, 0x1000 | (2<<6) | 3); /* clkfbout_mult = 5 */
mmcm->write(0x08, 0x1000 | (2<<6) | 3); /* clkout0_divide = 5 */
mmcm->write(0x0a, 0x1000 | (2<<6) | 2); /* clkout1_divide = 4 */
mmcm->write(0x0c, 0x1000 | (0<<6) | 0); /* clkout2_divide = 1 */
mmcm->write(0x0d, (1<<6)); /* clkout2_divide = 1 */
}

void mmcm_config_for_clock(int freq)
void mmcm_config_for_clock(MMCM *mmcm, int freq)
{
/*
* FIXME: we also need to configure phase detector
*/
if(freq < 3000)
wprintf("Frequency too low for input MMCMs\n");
else if(freq < 6000)
hdmi_in_0_config_30_60mhz();
mmcm_config_30to60mhz(mmcm);
else if(freq < 12000)
hdmi_in_0_config_60_120mhz();
mmcm_config_60to120mhz(mmcm);
else if(freq < 24000)
hdmi_in_0_config_120_240mhz();
mmcm_config_120to240mhz(mmcm);
else
wprintf("Frequency too high for input MMCMs\n");
}
#endif

void mmcm_dump(void)
void mmcm_dump(MMCM* mmcm)
{
int i;
#ifdef CSR_HDMI_OUT0_CLOCKING_MMCM_RESET_ADDR
wprintf("framebuffer MMCM:\n");
for(i=0;i<128;i++)
wprintf("%04x ", hdmi_out0_mmcm_read(i));
wputchar("\n");
printf("%04x ", mmcm->read(i));

}
void mmcm_dump_all(void)
{
int i;
#ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR
printf("framebuffer MMCM:\n");
mmcm_dump(&hdmi_out0_driver_clocking_mmcm);
printf("\n");
#endif
#ifdef CSR_HDMI_IN0_CLOCKING_MMCM_RESET_ADDR
wprintf("dvisampler MMCM:\n");
for(i=0;i<128;i++)
wprintf("%04x ", hdmi_in0_clocking_mmcm_read(i));
wputchar('\n');
printf("dvisampler MMCM:\n");
mmcm_dump(&hdmi_in0_clocking_mmcm);
printf("\n");
#endif
}
26 changes: 19 additions & 7 deletions firmware/mmcm.h
Original file line number Diff line number Diff line change
@@ -3,16 +3,28 @@

#include <generated/csr.h>

#ifdef CSR_HDMI_IN0_CLOCKING_MMCM_RESET_ADDR
typedef void (*mmcm_write_t)(int,int);
typedef int (*mmcm_read_t)(int);

void hdmi_out0_mmcm_write(int adr, int data);
int hdmi_out0_mmcm_read(int adr);
void hdmi_in0_clocking_mmcm_write(int adr, int data);
int hdmi_in0_clocking_mmcm_read(int adr);
typedef struct {
mmcm_write_t write;
mmcm_read_t read;
} MMCM;

void mmcm_config_for_clock(MMCM *mmcm, int freq);
void mmcm_dump(MMCM *mmcm);
void mmcm_dump_all(void);

void mmcm_config_for_clock(int freq);
#ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR
void hdmi_out0_driver_clocking_mmcm_write(int adr, int data);
int hdmi_out0_driver_clocking_mmcm_read(int adr);
extern MMCM hdmi_out0_driver_clocking_mmcm;
#endif

void mmcm_dump(void);
#ifdef CSR_HDMI_IN0_CLOCKING_MMCM_RESET_ADDR
void hdmi_in0_clocking_mmcm_write(int adr, int data);
int hdmi_in0_clocking_mmcm_read(int adr);
extern MMCM hdmi_in0_clocking_mmcm;
#endif

#endif
Loading