Commit graph

44 commits

Author SHA1 Message Date
Anas Nashif a08bfeb49c syscall: rename Z_OOPS -> K_OOPS
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 1a9de05767 syscall: rename Z_SYSCALL_DRIVER_ -> K_SYSCALL_DRIVER_
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 56fddd805a syscall: rename z_user_from_copy -> k_usermode_from_copy
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 4e396174ce kernel: move syscall_handler.h to internal include directory
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Daniel Leung 26ecaba4af drivers: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Gerard Marull-Paretas b2d9212ea0 drivers: all: mchp_xec: remove conditional support for pinctrl
The Microchip XEC platform always uses pinctrl, there's no need to keep
extra macrology around pinctrl. Also updated driver's Kconfig options to
`select PINCTRL`.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-24 13:34:22 +02:00
Gerard Marull-Paretas 0ebe14beb4 sys: util: migrate all files to DIV_ROUND_UP
ceiling_fraction is deprecated, use DIV_ROUND_UP.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-11 12:00:37 +02:00
Manimaran A 535d64cd44 drivers: peci: microchip: Enabled low power mode
Updated the PECI driver to support low power mode.

Signed-off-by: Manimaran A <manimaran.a@microchip.com>
2023-04-07 13:30:40 +02:00
Pieter De Gendt 6b532ff43e treewide: Update clock control API usage
Replace all (clock_control_subsys_t *) casts with (clock_control_subsys_t)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-05 10:55:46 +02:00
Henrik Brix Andersen 2ff049d652 drivers: peci: move CONFIG_PECI_INTERRUPT_DRIVEN inside if statement
Move CONFIG_PECI_INTERRUPT_DRIVEN inside the CONFIG_PECI if statement to
avoid showing it in menuconfig when PECI drivers are disabled.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-04-04 13:49:52 +02:00
Henrik Brix Andersen c41dd36de2 drivers: kconfig: unify menuconfig title strings
Unify the drivers/*/Kconfig menuconfig title strings to the format
"<class> [(acronym)] [bus] drivers".

Including both the full name of the driver class and an acronym makes
menuconfig more user friendly as some of the acronyms are less well-known
than others. It also improves Kconfig search, both via menuconfig and via
the generated Kconfig documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-28 15:06:06 +02:00
Jay Vasanth acf473f850 driver: peci: mec: enable peci in ec subsystem register
Ensure that PECI block is enabled in the EC Subsystem by clearing
the PECI_DIS (peci disable) register

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2022-11-10 22:39:43 -05:00
Tim Lin 0789442132 ITE: soc: chip_chipregs: Access registers using structure method
Access registers using structure method.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-11-09 10:44:29 +01:00
Gerard Marull-Paretas b1a0d0ae86 include: add missing zephyr/kernel.h
Some files were using the Kernel APIs/types without including
zephyr/kernel.h.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-20 22:52:09 +09:00
Gerard Marull-Paretas 178bdc4afc include: add missing zephyr/irq.h include
Change automated searching for files using "IRQ_CONNECT()" API not
including <zephyr/irq.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 22:57:39 +09:00
Anas Nashif 3d85ae37b6 arm: add missing includes
Add missing includes that were previously included indirectly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 18:37:53 -04:00
Kumar Gala 210044b788 drivers: peci: Update Kconfig
* Utilize DT_HAS_<COMPAT>_ENABLED for devicetree based drivers

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-16 08:26:11 +00:00
Kumar Gala 19801debc5 peci: ite_it8xxx2: Move interrupt select to driver Kconfig
The driver really should select PECI_INTERRUPT_DRIVEN instead
of doing it in the SoC Kconfig.defconfig.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-12 14:16:59 +01:00
Kumar Gala 89f356a0ff peci: ite_it8xxx2: Rename compatiable to match other compatiables
All the of the ITE it8xxx2 devicetree compatiables are of the form
ite,it8xxx2-<DEV>.  However the PECI device was ite,peci-it8xxx2,
rename the compatiable to match the pattern used everywhere else.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-12 14:16:59 +01:00
Jun Lin ec4f700202 driver: PECI: npcx: add driver support for Nuvoton npcx family
This commit add the PECI driver for Nuvoton npcx family to support PECI
APIs.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2022-07-29 14:09:17 +02:00
Gerard Marull-Paretas fb60aab245 drivers: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all drivers to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 19:58:21 +02:00
Tim Lin 3670977158 ITE: drivers/peci: Use pinctrl instead of pinmux driver
Use pinctrl instead of pinmux driver.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-05-06 11:32:40 +02:00
Johannes Meister 7d1c15d09e drivers: peci: xec: Handle PECI command PING properly
Handle PECI command PING properly, also get Write FCS Byte as a check.
Now it is possible to perform a PECI Ping without crashing the bus or
blocking it for subsequent PECI transactions.
It is also possible to check whether the Ping was sucessful
or not with the Write FCS Byte.

Signed-off-by: Johannes Meister <johannes.meister@kontron.com>
2022-04-21 07:45:45 -05:00
Jay Vasanth bbec77c982 drivers: peci: Microchip XEC PECI driver add PINCTRL support
Add PINCTRL support to Microchip XEC PECI driver shared by
MEC172x and MEC15xx families.

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2022-04-05 11:16:41 +02:00
Jay Vasanth 9777c5e90e drivers: peci: Microchip XEC PECI driver add MEC172x support
Update Microchip XEC PECI driver to support MEC172x.

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2022-04-05 11:16:41 +02:00
Jay Vasanth 822e3bb612 drivers: peci: Microchip XEC PECI driver standardize
Standarize device structure usage for mchp peci driver

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2022-04-05 11:16:41 +02:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Jose Alberto Meza f7b5d4b06a drivers: peci: xec: Handle corner case for PECI recovery
Handle case where PECI recovery occurs in ISR context.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2022-02-21 20:58:26 -05:00
BJ Chen 59cd9fd551 ITE: drivers/peci: Add PECI driver module of ITE IT8xxx2
Added the PECI driver tested with the samples/drivers/peci.

Signed-off-by: BJ Chen <bj.chen@ite.com.tw>
2022-02-21 19:43:40 -05:00
Gerard Marull-Paretas aa1c8e2ee9 drivers: peci: remove usage of device_pm_control_nop
device_pm_control_nop is now deprecated in favour of NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 12:25:24 -04:00
Diwakar C c860b86822 driver: peci: Wait until rx fifo gets filled up
While running certain peci command, observed when FW attempts
to read last byte (Response FCS), PECI host controller returned
“Read FIFO” empty. Since “Read FIFO” is empty FW didn’t read
the response FCS.

Due to this issue, FW getting corrupted response from the PECI
controller for all the subsequent PECI commands.

To address this issue, FW waits for “Read FIFO” filled up by
the PECI controller.

Signed-off-by: Diwakar C <diwakar.c@intel.com>
2021-02-17 04:05:11 -05:00
Kumar Gala 640437003f drivers: peci: Convert drivers to new DT device macros
Convert peci drivers from:

	DEVICE_AND_API_INIT -> DEVICE_DT_INST_DEFINE

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-15 15:17:59 -06:00
Jose Alberto Meza 387e3e4477 drivers: peci: xec: Enhance PECI bus recovery mechanism
Perform FIFO flush in write failure case
Perform full PECI HW block reset if multiple consecutive
failures are observed
Remove trailing \n from logging messages

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2020-11-19 17:00:16 -05:00
Diwakar C 909072d012 peci: driver: Ping cmd fail due to improper tx len and wait handling
In current implementation, for Ping command, write data/payload is
queued in FIFO infinitely eventhough Ping command have write length
of '0'.

This issue is addressed in this patch.

Signed-off-by: Diwakar C <diwakar.c@intel.com>
2020-11-09 15:49:19 -06:00
Rajavardhan Gundi 7d3dde5e5e drivers: peci: xec: Fix error recovery handling
Fix the error recovery mechanism that makes use of a temp variable
to avoid coverity issue without breaking error recovery.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2020-09-15 12:35:15 -05:00
Tomasz Bursztyka 4dcfb5531c isr: Normalize usage of device instance through ISR
The goal of this patch is to replace the 'void *' parameter by 'struct
device *' if they use such variable or just 'const void *' on all
relevant ISRs

This will avoid not-so-nice const qualifier tweaks when device instances
will be constant.

Note that only the ISR passed to IRQ_CONNECT are of interest here.

In order to do so, the script fix_isr.py below is necessary:

from pathlib import Path
import subprocess
import pickle
import mmap
import sys
import re
import os

cocci_template = """
@r_fix_isr_0
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
 ...
(
 const struct device *D = (const struct device *)P;
|
 const struct device *D = P;
)
 ...
}

@r_fix_isr_1
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
 ...
 const struct device *D;
 ...
(
 D = (const struct device *)P;
|
 D = P;
)
 ...
}

@r_fix_isr_2
@
type ret_type;
identifier A;
@@
-ret_type <!fn!>(void *A)
+ret_type <!fn!>(const void *A)
{
 ...
}

@r_fix_isr_3
@
const struct device *D;
@@
-<!fn!>((void *)D);
+<!fn!>(D);

@r_fix_isr_4
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
 ...
(
-const struct device *D = (const struct device *)P;
|
-const struct device *D = P;
)
 ...
}

@r_fix_isr_5
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
 ...
-const struct device *D;
...
(
-D = (const struct device *)P;
|
-D = P;
)
 ...
}
"""

def find_isr(fn):
    db = []
    data = None
    start = 0

    try:
        with open(fn, 'r+') as f:
            data = str(mmap.mmap(f.fileno(), 0).read())
    except Exception as e:
        return db

    while True:
        isr = ""
        irq = data.find('IRQ_CONNECT', start)
        while irq > -1:
            p = 1
            arg = 1
            p_o = data.find('(', irq)
            if p_o < 0:
                irq = -1
                break;

            pos = p_o + 1

            while p > 0:
                if data[pos] == ')':
                    p -= 1
                elif data[pos] == '(':
                    p += 1
                elif data[pos] == ',' and p == 1:
                    arg += 1

                if arg == 3:
                    isr += data[pos]

                pos += 1

            isr = isr.strip(',\\n\\t ')
            if isr not in db and len(isr) > 0:
                db.append(isr)

            start = pos
            break

        if irq < 0:
            break

    return db

def patch_isr(fn, isr_list):
    if len(isr_list) <= 0:
        return

    for isr in isr_list:
        tmplt = cocci_template.replace('<!fn!>', isr)
        with open('/tmp/isr_fix.cocci', 'w') as f:
            f.write(tmplt)

        cmd = ['spatch', '--sp-file', '/tmp/isr_fix.cocci', '--in-place', fn]

        subprocess.run(cmd)

def process_files(path):
    if path.is_file() and path.suffix in ['.h', '.c']:
        p = str(path.parent) + '/' + path.name
        isr_list = find_isr(p)
        patch_isr(p, isr_list)
    elif path.is_dir():
        for p in path.iterdir():
            process_files(p)

if len(sys.argv) < 2:
    print("You need to provide a dir/file path")
    sys.exit(1)

process_files(Path(sys.argv[1]))

And is run: ./fix_isr.py <zephyr root directory>

Finally, some files needed manual fixes such.

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Flavio Ceolin c07f71e3fe drivers: peci: Add verification handlers
Add verification handlers for syscalls defined in peci driver.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-05-25 18:06:22 +02:00
Kumar Gala 7a81cd9747 drivers: microchip: Convert microchip drivers to new DT_INST macros
Convert older DT_INST_ macro use in microchip drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 16:31:52 -05:00
Jose Alberto Meza 04e190ab87 drivers: peci: xec: Re-add error recovery handling
Using temp variable to avoid coverity issue without breakin
error recovery.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2020-03-23 17:16:46 -07:00
Anas Nashif 24f77ca167 drivers: peci: remove self-assignment
Assigning "base->ERROR" to itself has no effect.

Fixes #23586

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-23 14:10:58 -04:00
Jose Alberto Meza 55e6b294f2 drivers: peci: Add PECI driver for microchip XEC family
Add PECI driver that support PECI API.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2020-03-13 18:53:04 +02:00
Jose Alberto Meza 0de98c1bce drivers: peci: Add Kconfig for PECI driver
Add the Kconfig for generic PECI drivers.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2020-03-13 18:53:04 +02:00