Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New QL LED driver #3

Open
wants to merge 20 commits into
base: eos-s3-support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8bc4dfe
Modified e0s-s3-hal remote path
spingaliQL May 27, 2020
e0d1cd8
Merge pull request #1 from QuickLogic-Corp/manifest_changes
spingaliQL May 27, 2020
c6d0b60
added new led driver for S3. Added qf_helloworldhw sample. The led dr…
spingaliQL May 29, 2020
23a41e9
Merge pull request #2 from QuickLogic-Corp/qf_helloworldhw
spingaliQL May 29, 2020
a41c59c
Load litex PWM FPGA from M4
spingaliQL Jun 5, 2020
4fd38e5
Merge pull request #3 from QuickLogic-Corp/eos_s3_pwm_loader
spingaliQL Jun 5, 2020
ddf3b96
moved qf_hellowworld sample to led driver samples
spingaliQL Jun 9, 2020
a4d3c29
Merge pull request #4 from QuickLogic-Corp/eos_s3_led_sample1
spingaliQL Jun 15, 2020
6482500
Fix:Removed Hello world print.
spingaliQL Jun 15, 2020
b79b107
Merge pull request #5 from QuickLogic-Corp/eos_s3_led_sample1
spingaliQL Jun 15, 2020
4d24409
Changed offset and added sleep after write
spingaliQL Jun 17, 2020
a2f81ec
Changes for flash samples
spingaliQL Jun 25, 2020
bebbda4
Merge branch 'eos-s3-support' of https://github.com/QuickLogic-Corp/z…
spingaliQL Jun 26, 2020
ef50ce5
Changes for Antmicro code review
spingaliQL Jun 26, 2020
d734cd4
Merge branch 'code_review_changes1' into spi_flash_samples
spingaliQL Jun 26, 2020
077d7dc
Merge pull request #6 from QuickLogic-Corp/code_review_changes1
spingaliQL Jun 26, 2020
0a68171
Merge branch 'eos-s3-support' of https://github.com/QuickLogic-Corp/z…
spingaliQL Jun 26, 2020
be93005
Merge pull request #7 from QuickLogic-Corp/spi_flash_samples
spingaliQL Jun 26, 2020
4c72824
spi flash sample offset fix
spingaliQL Jul 7, 2020
09ce621
Merge pull request #8 from QuickLogic-Corp/spi_flash_sample_fix
spingaliQL Jul 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions boards/arm/quick_feather/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ if PWM

config PWM_LITEX
select SOC_EOS_S3_FPGA
default n

config EOS_S3_PWM
select EOS_S3_PROGRAM_FPGA

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not change this selection, because SOC_EOS_S3_FPGA configuration tells software if we want to initialize FPGA or not here. Without it clocks won't be set up.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main change I made in these commits is to program FPGA from M4 program itself, instead of doing it outside using Jlink. To enable this feature I have added EOS_S3_PROGRAM_FPGA. If someone wants to use the old way, one can enable SOC_EOS_S3_FPGA. I have not made any changes in this flow. Since all clocks are enabled with EOS_S3_PROGRAM_FPGA, other is not required. So EOS_S3_PROGRAM_FPGA and SOC_EOS_S3_FPGA are mutually exclusive.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does eos_s3_pwm_ip.h contain PWM_LITEX? If not you must add separate config entry like explained here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it doesn't.
I'll add separate config entry.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added new configuration. However I understand from our H/W team that we are using litex pwm IP only, the bit stream is generated using symbi flow tools (with EOS S3 support). Our driver just loads the FPGA IP. It doesn't have full functions. For that I have to use pwm litex driver. So I have included that too.

default y

kowalewskijan marked this conversation as resolved.
Show resolved Hide resolved
endif # PWM
Expand Down
2 changes: 1 addition & 1 deletion boards/arm/quick_feather/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static int eos_s3_board_init(struct device *arg)
eos_s3_io_mux(SPI_SS1_PAD, SPI_SS1_PAD_CFG);
#endif

#ifdef CONFIG_PWM_LITEX
#if defined CONFIG_PWM_LITEX || CONFIG_EOS_S3_PWM
eos_s3_io_mux(PWM0_PAD, PWM0_PAD_CFG);
eos_s3_io_mux(PWM1_PAD, PWM1_PAD_CFG);
eos_s3_io_mux(PWM2_PAD, PWM2_PAD_CFG);
Expand Down
2 changes: 1 addition & 1 deletion boards/arm/quick_feather/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define SPI_SS1_PAD_CFG SPI_SS1_PAD39
#endif /* CONFIG_SPI_EOS_S3 */

#ifdef CONFIG_PWM_LITEX
#if defined CONFIG_PWM_LITEX || CONFIG_EOS_S3_PWM
/* FPGA IP core peripherals */
#define DT_PWM_GEN_EOS_S3_BASE_ADDRESS DT_QUICKLOGIC_EOS_S3_PWM_GEN_40020000_BASE_ADDRESS
#define DT_PWM_GEN_EOS_S3_DIVIDER DT_QUICKLOGIC_EOS_S3_PWM_GEN_40020000_DIVIDER
Expand Down
17 changes: 13 additions & 4 deletions boards/arm/quick_feather/quick_feather.dts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
* 0x0001ffff (sectors 16-31) is reserved for use
* by the application.
*/
storage_partition: partition@10000 {
label = "storage";
metadata_partition: partition@10000 {
label = "metadata";
reg = <0x00010000 0x00010000>;
};

Expand All @@ -145,9 +145,18 @@
label = "image-1";
reg = <0x00040000 0x00020000>;
};
scratch_partition: partition@60000 {
label = "image-scratch";
slot2_partition: partition@60000 {
label = "image-2";
reg = <0x00060000 0x00020000>;
};
slot3_partition: partition@80000 {
label = "image-3";
reg = <0x00080000 0x00020000>;
};
storage_partition: partition@100000 {
label = "storage";
reg = <0x00100000 0x00010000>;
};

};
};
1 change: 1 addition & 0 deletions drivers/led/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ zephyr_sources_ifdef(CONFIG_HT16K33 ht16k33.c)
zephyr_sources_ifdef(CONFIG_LP3943 lp3943.c)
zephyr_sources_ifdef(CONFIG_LP5562 lp5562.c)
zephyr_sources_ifdef(CONFIG_PCA9633 pca9633.c)
zephyr_sources_ifdef(CONFIG_EOS_S3_LED_BASIC led_eos_s3_basic.c)

zephyr_sources_ifdef(CONFIG_USERSPACE led_handlers.c)
1 change: 1 addition & 0 deletions drivers/led/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ source "drivers/led/Kconfig.ht16k33"
source "drivers/led/Kconfig.lp3943"
source "drivers/led/Kconfig.lp5562"
source "drivers/led/Kconfig.pca9633"
source "drivers/led/Kconfig.eos_s3_basic"

endif # LED
8 changes: 8 additions & 0 deletions drivers/led/Kconfig.eos_s3_basic
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2020 QuickLogic
# Licensed under the Apache License, Version 2.0

config EOS_S3_LED_BASIC
bool "EOS S3 basic LED driver"
help
Enable basic LED driver for QL S3.

1,901 changes: 1,901 additions & 0 deletions drivers/led/eos_s3_led_basic_ip.h

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions drivers/led/eos_s3_led_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* ==========================================================
*
* Copyright (C) 2020 QuickLogic Corporation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* File : eos_s3_led_config.h
* Purpose : This file contains the IO mux definitions for LEDs
*
*
* ===========================================================
*
*/


#ifndef _INC_EOS_S3_LED_CONFIG
#define _INC_EOS_S3_LED_CONFIG

#include <soc_pinmap.h>

/* Set FPGA_LED0 to PAD18 */
#define FPGA_LED0_PAD18 (PAD_CTRL_SEL_FPGA | PAD_OEN_NORMAL \
| PAD_P_Z | PAD_SR_SLOW | PAD_E_4MA \
| PAD_REN_DISABLE | PAD_SMT_DISABLE)
#define FPGA_LED0_PAD18_FBIO PAD18_FUNC_SEL_FBIO_18

/* Set FPGA_LED1 to PAD21 */
#define FPGA_LED1_PAD21 (PAD_CTRL_SEL_FPGA | PAD_OEN_NORMAL \
| PAD_P_Z | PAD_SR_SLOW | PAD_E_4MA \
| PAD_REN_DISABLE | PAD_SMT_DISABLE)
#define FPGA_LED1_PAD21_FBIO PAD21_FUNC_SEL_FBIO_21

/* Set FPGA_LED2 to PAD22 */
#define FPGA_LED2_PAD22 (PAD_CTRL_SEL_FPGA | PAD_OEN_NORMAL \
| PAD_P_Z | PAD_SR_SLOW | PAD_E_4MA \
| PAD_REN_DISABLE | PAD_SMT_DISABLE)
#define FPGA_LED2_PAD22_FBIO PAD22_FUNC_SEL_FBIO_22

#define FPGA_LED0_PAD 18
#define FPGA_LED0_PAD_CFG FPGA_LED0_PAD18
#define FPGA_LED0_FBIO_SEL FPGA_LED0_PAD18_FBIO
#define FPGA_LED1_PAD 21
#define FPGA_LED1_PAD_CFG FPGA_LED1_PAD21
#define FPGA_LED1_FBIO_SEL FPGA_LED1_PAD21_FBIO
#define FPGA_LED2_PAD 22
#define FPGA_LED2_PAD_CFG FPGA_LED2_PAD22
#define FPGA_LED2_FBIO_SEL FPGA_LED2_PAD22_FBIO


#endif /* _INC_EOS_S3_LED_CONFIG */
49 changes: 49 additions & 0 deletions drivers/led/led_eos_s3_basic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* ==========================================================
*
* Copyright (C) 2020 QuickLogic Corporation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* File : led_eos_s3_basic.c
* Purpose : This is the driver for basic LED controller IP.
*
*
* ===========================================================
*
*/

#include <zephyr.h>
#include <soc.h>
#include <fpga_loader.h>
#include "eos_s3_led_basic_ip.h"
#include "eos_s3_led_config.h"

static void config_ios(void)
{
eos_s3_io_mux(FPGA_LED0_PAD, FPGA_LED0_PAD_CFG);
eos_s3_io_mux(FPGA_LED1_PAD, FPGA_LED1_PAD_CFG);
eos_s3_io_mux(FPGA_LED2_PAD, FPGA_LED2_PAD_CFG);

eos_s3_fbio_select(FPGA_LED0_PAD, FPGA_LED0_FBIO_SEL);
eos_s3_fbio_select(FPGA_LED1_PAD, FPGA_LED1_FBIO_SEL);
eos_s3_fbio_select(FPGA_LED2_PAD, FPGA_LED2_FBIO_SEL);

}

void program_fpga_ip(void)
Copy link

@kowalewskijan kowalewskijan Jul 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about loading bitstream inside other drivers and I came to conclusion that the best solution would be to introduce a new type of driver in Zephyr - FPGA manager. We should add drivers/fpga directory in Zephyr, add global Kconfig and Kconfig.eos_s3 and add there a new driver exclusively for FPGA control, like: FPGA init, FPGA bitstream loading etc. So in the end there would be 2 separate layers - 1st: FPGA control related and 2nd: driver for IPcore. This would allow us to upload bitstream at early boot stage and later use IP core drivers without special FPGA managing functions.

{
/* Load bitstrem into FPGA */
load_fpga(sizeof(axFPGABitStream), axFPGABitStream);

/* Configure IOs */
config_ios();
}

2 changes: 2 additions & 0 deletions drivers/pwm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ zephyr_library_sources_ifdef(CONFIG_PWM_SAM pwm_sam.c)
zephyr_library_sources_ifdef(CONFIG_PWM_MCUX pwm_mcux.c)
zephyr_library_sources_ifdef(CONFIG_PWM_XEC pwm_mchp_xec.c)
zephyr_library_sources_ifdef(CONFIG_PWM_LITEX pwm_litex.c)
zephyr_library_sources_ifdef(CONFIG_EOS_S3_PWM pwm_litex.c)
zephyr_library_sources_ifdef(CONFIG_EOS_S3_PWM pwm_eos_s3.c)

zephyr_library_sources_ifdef(CONFIG_USERSPACE pwm_handlers.c)
zephyr_library_sources_ifdef(CONFIG_PWM_SHELL pwm_shell.c)
2 changes: 2 additions & 0 deletions drivers/pwm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ source "drivers/pwm/Kconfig.xec"

source "drivers/pwm/Kconfig.litex"

source "drivers/pwm/Kconfig.eos_s3"

endif # PWM
18 changes: 18 additions & 0 deletions drivers/pwm/Kconfig.eos_s3
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2020 QuickLogic
# Licensed under the Apache License, Version 2.0

menuconfig EOS_S3_PWM
bool "EOS S3 LiteX PWM driver"
depends on HAS_DTS
help
Set if PWM IP generated with EOS S3 tools

if EOS_S3_PWM

config PWM_LITEX_INIT_PRIORITY
int "Init priority"
default 70
help
PWM device driver initialization priority.

endif # PWM_LITEX
Loading