Commit graph

55 commits

Author SHA1 Message Date
Tim Lin
a8e467cf2d soc/ite/ec/common: Rename functions to use generic names
Renamed two functions and a macro to use more generic names,
removing chip-specific identifiers.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-06-05 09:34:23 +02:00
Tim Lin
4aaa0f8547 soc/ite/ec: it51xxx: Add condition to select the mode based on CONFIG_ESPI
If CONFIG_ESPI is defined, use 0xA4 (eSPI mode).
Otherwise, use 0xA5 (LPC mode).

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-06-05 09:34:23 +02:00
Tim Lin
5f502499e9 drivers/espi: ite: Refactor register defines into .c for SoC flexibility
Move register definitions from chip_chipregs.h into espi_it8xxx2.c to
make the driver more adaptable to different SoCs.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-06-05 09:34:23 +02:00
Tim Lin
022043c6f6 soc/ite/ec: it51xxx: Add a new SoC variant it51526bw
1. Add it51526bw SoC variant to it51xxx SoC series.
2. Create the .dtsi file with adjusted flash size for 512Kb (default = 1M).

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-05-29 08:42:08 +02:00
Yunshao Chiang
8f8b223ff2 drivers: crypto: add it51xxx sha256 driver
Implement a crypto sha256 driver for it51xxx series.

Signed-off-by: Yunshao Chiang <Yunshao.Chiang@ite.com.tw>
2025-05-16 19:07:37 +02:00
Tim Lin
f7d381fef1 drivers/i2c: Add I2C driver of it51xxx
Implement the functions of I2C host and target.
I2CM: supports nine hosts and each one able located at I2C interface
      0~12.
      supports two 32 bytes dedicated FIFO mode for read and write.
I2CS: supports three targets and each one able located at I2C
      interface 0~8.
      supports 16 bytes dedicated FIFO mode that only supports write or
      read mode and the maximum buffer size is 256 bytes.
      support non-FIFO write to shared FIFO read mode. The maximum
      shared FIFO size for read is 256 bytes.
The APIs test include: i2c_write(), i2c_read(), i2c_burst_read(),
                       i2c_burst_write(), i2c_write_read()

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-04-29 16:48:06 +02:00
Ruibin Chang
eb99158a80 drivers/sensor/ite/tach/it51xxx: implement tachometer driver
Implement tachometer driver for ITE it51xxx series chip.

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2025-04-24 11:56:44 +02:00
Tim Lin
f3ddb06028 soc: ite: ilm: it51xxx: Support RAM code size up to 4K
Previously, the RAM code size was limited to 1K, causing issues when the
code exceeded this limit. This update modifies the implementation to
support RAM code sizes up to 4K

test: zephyrproject/zephyr/tests/drivers/flash/common --> pass

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-04-11 06:34:15 +02:00
Tim Lin
a531e71376 drivers/timer: Add timer driver of it51xxx
Add timer driver for ITE it51xxx series.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-04-08 10:48:26 +02:00
Tim Lin
df56c85e94 drivers/clock: Add clock drivers of it51xxx
Add clock drivers for ITE it51xxx series.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-04-08 10:48:26 +02:00
Tim Lin
8c2f5684bb drivers/flash: Enable flash controller for it51xxx series
Enable flash controller for ITE it51xxx series.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-04-08 10:48:26 +02:00
Tim Lin
d9571f6412 soc: ITE: ilm: Enable instruction memory for it51xxx series
Enable instruction memory for ITE it51xxx series.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-04-08 10:48:26 +02:00
Tim Lin
f0d21fb497 drivers/pinctrl: Enable pinctrl driver for it51xxx series
Enable pinctrl driver for ITE it51xxx series.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-04-08 10:48:26 +02:00
Tim Lin
7a06df9cc3 soc: ITE: Add ITE it51xxx SoC
Add support for ITE it51xxx SoC.
NOTE: it51526aw is not support RISCV_ISA_EXT_C.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-04-08 10:48:26 +02:00
Tim Lin
0e5218cbcc drivers: ITE: Use generic name instead of specific chip name
Use generic name for structure in driver instead of specific chip name
for better compatibility.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-04-08 10:48:26 +02:00
Tim Lin
09f25854b3 soc: Separate it8xxx2 related files from the common folder
Some files should be separated from the common folder to
each soc folder for future expansion of the chip.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-04-08 10:48:26 +02:00
Tim Lin
c7e6cfb8cb soc/ite/ec: common: Modify the format to comply with check_compliance.py
Modify the format to comply with check_compliance.py.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-04-08 10:48:26 +02:00
Tim Lin
8d855a270f soc: ite: it8xxx2: Disable I2C0 alternate function to allow sleep entry
The chip requires a successful sleep entry to change the PLL sequence.
By default, the IT8XXX2 chip enables the I2C0 alternate function, which
can cause the clock/data lines to meet the start condition, preventing
EC from entering sleep mode.

This commit disables the I2C0 alternate function before executing the
PLL sequence change to ensure that the EC can enter sleep mode
successfully.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-03-31 14:35:35 +02:00
Keith Short
6b61973e39 ite/it8xxx2: Fix JTAG support when using a flash offset
If a board defined CONFIG_FLASH_LOAD_OFFSET to a non-zero value,
enabling CONFIG_SOC_IT8XXX2_JTAG_DEBUG_INTERFACE generated a linker
error because when trying to move the location counter backwards.

Fixed by allocating the JTAG section within the deined ROM region.

Signed-off-by: Keith Short <keithshort@google.com>
2025-02-22 07:12:47 +01:00
Fabio Baltieri
c06202c176 it82xx2_evb: drop PM symbols from the board config
PM, PM_DEVICE etc should be enabled by the application/samples, not the
board.

Add a config to default to custom policy for the board though since
there's one defined at soc level.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-02-21 04:39:05 +01:00
Yong Cong Sin
e6dd68ec89 arch: riscv: introduce CONFIG_RISCV_GP_PURPOSE choice
Introduce `CONFIG_RISCV_GP_PURPOSE` choice to make sure that only
one of `CONFIG_RISCV_GP` or `CONFIG_RISCV_CURRENT_VIA_GP` can be
enabled, instead of relying of dependencies.

To do that, introduce a new
`CONFIG_RISCV_SOC_HAS_GP_RELATIVE_ADDRESSING` that can be selected
by SoC when it implemented global pointer (GP) initialization for
relative addressing in its linker.

`CONFIG_RISCV_GP` will be the default choice when
`CONFIG_RISCV_SOC_HAS_GP_RELATIVE_ADDRESSING=y`

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-11-28 12:51:09 +01:00
Dino Li
e59289d899 soc/it8xxx2: disable USB debug path at default
This change disables USB debug path at default, in order to prevent SoC
from entering debug mode when there is signal toggling on GPH5/GPH6.

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
2024-11-25 08:30:48 +01:00
Tim Lin
7fa962589f ITE: it8xxx2: Remove CONFIG_PINCTRL from soc defconfig file
The driver Kconfig determines whether pinctrl is enabled
instead of soc defconfig.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-10-15 13:52:55 +02:00
Yong Cong Sin
52a202309b zephyr: bulk update to DT_NODE_HAS_STATUS_OKAY
Change instances of:

DT_NODE_HAS_STATUS(<node_id>, okay)

to

DT_NODE_HAS_STATUS_OKAY(<node_id>)

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-10-03 17:06:52 +01:00
Marcio Ribeiro
cb583995b8 arch: riscv: imply XIP config pushed to SoC level
'imply XIP' pushed from arch/Kconfig/'config RISCV' to riscv SoCs Kconfig
files to allow riscv SoCs having XIP enabled (or not) at SoC level

Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
2024-08-31 06:47:52 -04:00
Ren Chen
b90a507ba1 soc: ite: it8xxx2: support 96MHz PLL frequency and lcvco calibration
To enhance USB clock's accuracy, this change supports 96MHz PLL frequency
and LCVCO calibration.

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2024-08-29 11:38:20 +02:00
Anas Nashif
a91c6e56c8 arch: use same syntax for custom arch calls
Use same Kconfig syntax for those  custom arch call.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-08-12 12:43:36 +02:00
Anas Nashif
7f52fc4188 arch: custom cpu_idle and cpu_atomic harmonization
custom arch_cpu_idle and arch_cpu_atomic_idle implementation was done
differently on different architectures. riscv implemented those as weak
symbols, xtensa used a kconfig and all other architectures did not
really care, but this was a global kconfig that should apply to all
architectures.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-08-12 12:43:36 +02:00
Dino Li
c3a4a1a0f6 drivers: intc_ite_it8xxx2: disable debug mode then reset for tests
After flashed EC image, we needed to manually press the reset button
on it8xxx2_evb. Now, without pressing the button, we can disable
debug mode and trigger a watchdog hard reset for running tests.

After flash EC, running below tests can pass (without pressing the button):
west build -p always -b it8xxx2_evb tests/drivers/watchdog/wdt_basic_api
west build -p always -b it8xxx2_evb tests/kernel/timer/timer_api
west build -p always -b it8xxx2_evb tests/kernel/fatal/exception

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2024-08-08 06:07:35 -04:00
Tim Lin
6a4a164b54 soc: it8xxx2: linker: Move zephyr library to RAM to enhance performance
Place zephyr library in ILM. This can improve performance.

test:
Print the message 10000 times with 1ms sleep interval to compare the
time difference before and after adding RAM code on the it82002bw evb.

                         RAM code size     save time
original:                1954 bytes
libzephyr.a:            +16974 bytes      -608ms

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-07-27 20:49:47 +03:00
Tim Lin
2ab908bcf2 soc: it8xxx2: linker: Move kernel library to RAM to enhance performance
Place kernel library in ILM. This can improve performance.

test:
Print the message 10000 times with 1ms sleep interval to compare the
time difference before and after adding RAM code on the it82002bw evb.

                         RAM code size    save time
original:                1954 bytes
libkernel.a:            +8941 bytes      -649ms

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-07-27 20:49:47 +03:00
Tim Lin
c5cf53b690 soc: it8xxx2: linker: Move serial library to RAM to enhance performance
Place serial library in ILM. This can improve performance.

test:
Print the message 10000 times with 1ms sleep interval to compare the
time difference before and after adding RAM code on the it82002bw evb.

                         RAM code size    save time
original:                1954 bytes
libdrivers__serial.a:   +2282 bytes      -226ms

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-07-27 20:49:47 +03:00
Lingao Meng
302422ad9d everywhere: replace double words
import os
import re

common_words = set([
    'about', 'after', 'all', 'also', 'an', 'and',
     'any', 'are', 'as', 'at',
    'be', 'because', 'but', 'by', 'can', 'come',
    'could', 'day', 'do', 'even',
    'first', 'for', 'get', 'give', 'go', 'has',
    'have', 'he', 'her',
    'him', 'his', 'how', 'I', 'in', 'into', 'it',
    'its', 'just',
    'know', 'like', 'look', 'make', 'man', 'many',
    'me', 'more', 'my', 'new',
    'no', 'not', 'now', 'of', 'one', 'only', 'or',
    'other', 'our', 'out',
    'over', 'people', 'say', 'see', 'she', 'so',
    'some', 'take', 'tell', 'than',
    'their', 'them', 'then', 'there', 'these',
    'they', 'think',
    'this', 'time', 'two', 'up', 'use', 'very',
    'want', 'was', 'way',
    'we', 'well', 'what', 'when', 'which', 'who',
    'will', 'with', 'would',
    'year', 'you', 'your'
])

valid_extensions = set([
    'c', 'h', 'yaml', 'cmake', 'conf', 'txt', 'overlay',
    'rst', 'dtsi',
    'Kconfig', 'dts', 'defconfig', 'yml', 'ld', 'sh', 'py',
    'soc', 'cfg'
])

def filter_repeated_words(text):
    # Split the text into lines
    lines = text.split('\n')

    # Combine lines into a single string with unique separator
    combined_text = '/*sep*/'.join(lines)

    # Replace repeated words within a line
    def replace_within_line(match):
        return match.group(1)

    # Regex for matching repeated words within a line
    within_line_pattern =
	re.compile(r'\b(' +
		'|'.join(map(re.escape, common_words)) +
		r')\b\s+\b\1\b')
    combined_text = within_line_pattern.
		sub(replace_within_line, combined_text)

    # Replace repeated words across line boundaries
    def replace_across_lines(match):
        return match.group(1) + match.group(2)

    # Regex for matching repeated words across line boundaries
    across_lines_pattern = re.
		compile(r'\b(' + '|'.join(
			map(re.escape, common_words)) +
			r')\b(\s*[*\/\n\s]*)\b\1\b')
    combined_text = across_lines_pattern.
		sub(replace_across_lines, combined_text)

    # Split the text back into lines
    filtered_text = combined_text.split('/*sep*/')

    return '\n'.join(filtered_text)

def process_file(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        text = file.read()

    new_text = filter_repeated_words(text)

    with open(file_path, 'w', encoding='utf-8') as file:
        file.write(new_text)

def process_directory(directory_path):
    for root, dirs, files in os.walk(directory_path):
        dirs[:] = [d for d in dirs if not d.startswith('.')]
        for file in files:
            # Filter out hidden files
            if file.startswith('.'):
                continue
            file_extension = file.split('.')[-1]
            if
	file_extension in valid_extensions:  # 只处理指定后缀的文件
                file_path = os.path.join(root, file)
                print(f"Processed file: {file_path}")
                process_file(file_path)

directory_to_process = "/home/mi/works/github/zephyrproject/zephyr"
process_directory(directory_to_process)

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-06-25 06:05:35 -04:00
Pieter De Gendt
99366dd2be linker: Add ROM_SECTIONS location
Currently iterable sections as per the documentation are added with
zephyr_linker_sources(SECTIONS ...) after bss/noinit.
This commit allows putting sections after common-rom.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-06-20 12:08:58 -04:00
Tim Lin
76ced4a82d drivers: pinctrl: ITE: Add a property configure pin current strength
Add the property of drive-strength to drive a high or low current
selection. If this property is not configured, it is the default
setting. According to the SPEC, the default drive current selection
varies from different pins.
Define the high level 0b: 8mA
           low  level 1b: 4mA or 2mA

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-06-06 00:41:35 -07:00
Mathieu Choplain
8aa6ae43ce llext: add support for SLID-based linking
This commit introduces support for an alternate linking method in the
LLEXT subsystem, called "SLID" (short for Symbol Link Identifier),
enabled by the CONFIG_LLEXT_EXPORT_BUILTINS_BY_SLID Kconfig option.

SLID-based linking uses a unique identifier (integer) to identify
exported symbols, instead of using the symbol name as done currently.
This approach provides several benefits:
 * linking is faster because the comparison operation to determine
   whether we found the correct symbol in the export table is now an
   integer compare, instead of a string compare
 * binary size is reduced as symbol names can be dropped from the binary
 * confidentiality is improved as a side-effect, as symbol names are no
   longer present in the binary

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2024-06-03 15:29:34 -04:00
Yong Cong Sin
bbe5e1e6eb build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Tim Lin
d371a89c3f ITE: soc: Add the variant of it82002bw
Add the variant of it82002bw

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-05-13 11:39:10 +02:00
Tim Lin
682a4c936a ITE: soc: Add the variant of it81302dx
Add the variant of it81302dx

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-05-13 11:39:10 +02:00
Tim Lin
f89934451f ITE: soc: Add the variant of it81202dx
Add the variant of it81202dx

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-05-13 11:39:10 +02:00
Tim Lin
dc44966f02 ITE: soc: Kconfig: Cleanup it8xxx2 Kconfig
The ILM_MAX_SIZE of different chip variants can be declared in the
Kconfig of the respective variant.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-05-13 11:39:10 +02:00
Dino Li
f76f2928f1 espi/it8xxx2: enable EC to accept port 81 cycle
This allows EC to accept 2 bytes of port 80 data written from the Host.

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
2024-05-10 20:25:13 -04:00
Tim Lin
f80e53dcc8 ITE: soc: Add the variant of it82302bw
Add the variant of it82302bw.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-04-26 16:10:55 +02:00
Tim Lin
c3fb094e69 ITE: soc: Add the variant of it82202bw
Add the variant of it82202bw.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-04-26 16:10:55 +02:00
Tim Lin
3a9b253491 ITE: soc: Kconfig: Remove underscore makes config names consistent
Remove underscore makes config name consistent.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-04-26 16:10:55 +02:00
Tim Lin
6158031f78 ITE: soc: Modify Kconfig default declare
Using the SOC_IT8XXX2_REG_SET_V2 instead of constantly adding new
variants of the IT82XX2 SoC.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-04-26 16:10:55 +02:00
Ren Chen
9b8550a24a ite/it8xxx2: avoid cpu entering deep doze mode when JTAG is enabled
Prevent the CPU from entering deep doze mode when JTAG debug is enabled.
Additionally, The CPU address from 0x80000800 to 0x800008FF should be
reserved for JTAG debug usage. This commit reserves the area from the end
of the reset section to 0x800008FF if JTAG debug is enabled.

Tested with:
- west build -p always -b it82xx2_evb samples/hello_world/
       -DCONFIG_SOC_IT8XXX2_JTAG_DEBUG_INTERFACE=y

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2024-04-24 19:40:07 +00:00
Ruibin Chang
1d74cb74d9 drivers/crypto/crypto_it8xxx2_sha_v2.c: implement sha v2 for it82xx2 series
Implement a new version crypto_it8xxx2_sha_v2 driver for it82xx2 series.

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2024-04-24 09:55:46 +02:00
Dino Li
63848e0162 it8xxx2/linker: correct __ilm_ram_end
correct __ilm_ram_end

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2024-04-24 09:55:46 +02:00
Ruibin Chang
72895507af soc: it8xxx2: kconfig: define CONFIG for variant chip
Variant chip has different USBPD HW PHY, so FW needs
to apply different downstream CONFIG settings based on
the PHY version.

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2024-04-18 11:13:38 +02:00