Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
/soc/arm/nuvoton/ @ssekar15
/soc/arm/nuvoton_npcx/ @MulinChao @WealianLiao @ChiHuaL
/soc/arm/quicklogic_eos_s3/ @kowalewskijan @kgugala
/soc/arm/raspberrypi/ @yonsch
/soc/arm/silabs_exx32/efm32pg1b/ @rdmeneze
/soc/arm/silabs_exx32/efr32mg21/ @l-alfred
/soc/arm/st_stm32/ @erwango
Expand Down Expand Up @@ -118,6 +119,7 @@
/boards/arm/quick_feather/ @kowalewskijan @kgugala
/boards/arm/rak4631_nrf52840/ @gpaquet85
/boards/arm/rak5010_nrf52840/ @gpaquet85
/boards/arm/raspberrypi_pico/ @yonsch
/boards/arm/ronoth_lodev/ @NorthernDean
/boards/arm/xmc45_relax_kit/ @parthitce
/boards/arm/sam4e_xpro/ @nandojve
Expand Down Expand Up @@ -287,6 +289,7 @@
/drivers/serial/uart_mcux_iuart.c @Mani-Sadhasivam
/drivers/serial/Kconfig.rtt @carlescufi @pkral78
/drivers/serial/uart_rtt.c @carlescufi @pkral78
/drivers/serial/uart_raspberrypi.c @yonsch
/drivers/serial/Kconfig.xlnx @wjliang
/drivers/serial/uart_xlnx_ps.c @wjliang
/drivers/serial/uart_xlnx_uartlite.c @henrikbrixandersen
Expand Down Expand Up @@ -357,6 +360,7 @@
/dts/arm/nuvoton/npcx/ @MulinChao @WealianLiao @ChiHuaL
/dts/arm/nxp/ @MaureenHelm @mmahadevan108 @dleach02
/dts/arm/microchip/ @franciscomunoz @albertofloyd @scottwcpg
/dts/arm/raspberrypi/ @yonsch
/dts/arm/silabs/efm32_pg_1b.dtsi @rdmeneze
/dts/arm/silabs/efm32gg11b* @oanerer
/dts/arm/silabs/efm32_jg_pg* @chrta
Expand Down
6 changes: 6 additions & 0 deletions boards/arm/raspberrypi_pico/Kconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2021 Yonatan Schachter
# SPDX-License-Identifier: Apache-2.0

config BOARD_RPI_PICO
bool "Raspberry Pi Pico Board"
depends on SOC_RP2040
9 changes: 9 additions & 0 deletions boards/arm/raspberrypi_pico/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2021 Yonatan Schachter
# SPDX-License-Identifier: Apache-2.0

if BOARD_RPI_PICO

config BOARD
default "raspberrypi_pico"

endif # BOARD_RPI_PICO
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions boards/arm/raspberrypi_pico/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.. _raspberrypi_pico:

Raspberry Pi Pico
#################

Overview
********

The Raspberry Pi Pico is a small, low-cost, versatile board from
Raspberry Pi. It is equipped with an RP2040 SoC, an on-board LED,
a USB connector, and an SWD inteface. The USB bootloader allows it
to be flashed without any adapter, in a drag-and-drop manner.
It is also possible to flash and debug the Pico with its SWD interface,
using an external adapter.

Hardware
********
- Dual core Arm Cortex-M0+ processor running up to 133MHz
- 264KB on-chip SRAM
- 2MB on-board QSPI flash with XIP capabilities
- 26 GPIO pins
- 3 Analog inputs
- 2 UART peripherals
- 2 SPI controllers
- 2 I2C controllers
- 16 PWM channels
- USB 1.1 controller (host/device)
- 8 Programmable I/O (PIO) for custom peripherals
- On-board LED


.. figure:: img/raspberrypi_pico.png
:width: 150px
:align: center
:alt: Raspberry Pi Pico

Raspberry Pi Pico (Image courtesy of Raspberry Pi)

Supported Features
==================

The raspberrypi_pico board configuration supports the following
hardware features:

+-----------+------------+----------------------+
| Interface | Controller | Driver/Component |
+===========+============+======================+
| UART | on-chip | serial port |
+-----------+------------+----------------------+
61 changes: 61 additions & 0 deletions boards/arm/raspberrypi_pico/raspberrypi_pico.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2021 Yonatan Schachter
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;

#include <raspberrypi/rp2040.dtsi>

/ {
chosen {
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,console = &uart0;
};

leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = <&gpio0 25 GPIO_ACTIVE_LOW>;
label = "LED";
};
};

pwmleds {
compatible = "pwm-leds";
pwm_led0: pwm_led_0 {
pwms = <&pwm0 25 0>;
label = "PWM LED0";
};
};

aliases {
led0 = &led0;
pwm-led0 = &pwm_led0;
};
};

&flash0 {
/* 2MB of flash minus the 0x100 used for
* the second stage bootloader
*/
reg = <0x10000100 0x001fff00>;
};

&uart0 {
current-speed = <115200>;
status = "okay";
tx-pin = <0>;
rx-pin = <1>;
};

&gpio0 {
status = "okay";
};

&pwm0 {
status = "okay";
prescaler = <255>;
};
12 changes: 12 additions & 0 deletions boards/arm/raspberrypi_pico/raspberrypi_pico.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
identifier: raspberrypi_pico
name: RaspberryPi-Pico
type: mcu
arch: arm
flash: 2048
ram: 264
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- serial
9 changes: 9 additions & 0 deletions boards/arm/raspberrypi_pico/raspberrypi_pico_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CONFIG_SOC_SERIES_RP2XXX=y
CONFIG_SOC_RP2040=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=125000000
CONFIG_RP2_FLASH_W25Q080=y
CONFIG_SERIAL=y
CONFIG_LOG=y
CONFIG_LOG_PRINTK=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
1 change: 1 addition & 0 deletions drivers/gpio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ zephyr_library_sources_ifdef(CONFIG_GPIO_SAM4L gpio_sam4l.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_SX1509B gpio_sx1509b.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_INTEL_APL gpio_intel_apl.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_STELLARIS gpio_stellaris.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_RASPBERRYPI gpio_raspberrypi.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_RV32M1 gpio_rv32m1.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_HT16K33 gpio_ht16k33.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_LMP90XXX gpio_lmp90xxx.c)
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ source "drivers/gpio/Kconfig.xec"

source "drivers/gpio/Kconfig.stellaris"

source "drivers/gpio/Kconfig.raspberrypi"

source "drivers/gpio/Kconfig.rv32m1"

source "drivers/gpio/Kconfig.ht16k33"
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpio/Kconfig.raspberrypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2021 Yonatan Schachter
# SPDX-License-Identifier: Apache-2.0

config GPIO_RASPBERRYPI
bool "Raspberry Pi GPIO driver"
178 changes: 178 additions & 0 deletions drivers/gpio/gpio_raspberrypi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/*
* Copyright (c) 2021, Yonatan Schachter
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <errno.h>
#include <drivers/gpio.h>
#include <hardware/gpio.h>
#include <hardware/regs/intctrl.h>
#include <hardware/structs/iobank0.h>

#include "gpio_utils.h"

#define DT_DRV_COMPAT raspberrypi_rp2_gpio

#define IRQ_PRIORITY 0
#define ALL_EVENTS (GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE \
| GPIO_IRQ_LEVEL_LOW | GPIO_IRQ_LEVEL_HIGH)

struct gpio_raspberrypi_config {
struct gpio_driver_config common;
};

struct gpio_raspberrypi_data {
struct gpio_driver_data common;
sys_slist_t callbacks;
uint32_t int_enabled_mask;
};

static int gpio_raspberrypi_configure(const struct device *dev,
gpio_pin_t pin,
gpio_flags_t flags)
{
if (flags & GPIO_SINGLE_ENDED) {
return -ENOTSUP;
}

gpio_init(pin);

if (flags & GPIO_OUTPUT) {
gpio_set_dir(pin, GPIO_OUT);

if (flags & GPIO_OUTPUT_INIT_HIGH)
gpio_put(pin, 1);
else if (flags & GPIO_OUTPUT_INIT_LOW)
gpio_put(pin, 0);

} else if (flags & GPIO_INPUT) {
gpio_set_dir(pin, GPIO_IN);
if (flags & GPIO_PULL_UP)
gpio_pull_up(pin);
else if (flags & GPIO_PULL_DOWN)
gpio_pull_down(pin);
}

return 0;
}

static int gpio_raspberrypi_port_get_raw(const struct device *dev, uint32_t *value)
{
*value = gpio_get_all();
return 0;
}

static int gpio_raspberrypi_port_set_masked_raw(const struct device *port,
uint32_t mask, uint32_t value)
{
gpio_put_masked(mask, value);
return 0;
}

static int gpio_raspberrypi_port_set_bits_raw(const struct device *port,
uint32_t pins)
{
gpio_set_mask(pins);
return 0;
}

static int gpio_raspberrypi_port_clear_bits_raw(const struct device *port,
uint32_t pins)
{
gpio_clr_mask(pins);
return 0;
}

static int gpio_raspberrypi_port_toggle_bits(const struct device *port,
uint32_t pins)
{
gpio_xor_mask(pins);
return 0;
}

static int gpio_raspberrypi_pin_interrupt_configure(const struct device *dev,
gpio_pin_t pin,
enum gpio_int_mode mode,
enum gpio_int_trig trig)
{
uint32_t events = 0;
struct gpio_raspberrypi_data *data = dev->data;

if (mode != GPIO_INT_DISABLE) {
if (mode & GPIO_INT_EDGE) {
if (trig & GPIO_INT_LOW_0)
events |= GPIO_IRQ_EDGE_FALL;
if (trig & GPIO_INT_HIGH_1)
events |= GPIO_IRQ_EDGE_RISE;
} else {
if (trig & GPIO_INT_LOW_0)
events |= GPIO_IRQ_LEVEL_LOW;
if (trig & GPIO_INT_HIGH_1)
events |= GPIO_IRQ_LEVEL_HIGH;
}
gpio_set_irq_enabled(pin, events, true);
}
WRITE_BIT(data->int_enabled_mask, pin, mode != GPIO_INT_DISABLE);
return 0;
}

static int gpio_raspberrypi_manage_callback(const struct device *dev,
struct gpio_callback *callback, bool set)
{
struct gpio_raspberrypi_data *data = dev->data;

return gpio_manage_callback(&data->callbacks, callback, set);
}

static const struct gpio_driver_api gpio_raspberrypi_driver_api = {
.pin_configure = gpio_raspberrypi_configure,
.port_get_raw = gpio_raspberrypi_port_get_raw,
.port_set_masked_raw = gpio_raspberrypi_port_set_masked_raw,
.port_set_bits_raw = gpio_raspberrypi_port_set_bits_raw,
.port_clear_bits_raw = gpio_raspberrypi_port_clear_bits_raw,
.port_toggle_bits = gpio_raspberrypi_port_toggle_bits,
.pin_interrupt_configure = gpio_raspberrypi_pin_interrupt_configure,
.manage_callback = gpio_raspberrypi_manage_callback,
};

static void gpio_raspberrypi_isr(const struct device *dev)
{
struct gpio_raspberrypi_data *data = dev->data;
uint32_t pin;
uint32_t events;
io_irq_ctrl_hw_t *irq_ctrl_base;
io_rw_32 *status_reg;

irq_ctrl_base = &iobank0_hw->proc0_irq_ctrl;
for (pin = 0; pin < NUM_BANK0_GPIOS; pin++) {
status_reg = &irq_ctrl_base->ints[pin / 8];
events = (*status_reg >> 4 * (pin % 8)) & ALL_EVENTS;
if (events) {
gpio_acknowledge_irq(pin, ALL_EVENTS);
gpio_fire_callbacks(&data->callbacks, dev, BIT(pin));
}
}
}

static int gpio_raspberrypi_init(const struct device *dev)
{
IRQ_CONNECT(IO_IRQ_BANK0, IRQ_PRIORITY, gpio_raspberrypi_isr,
DEVICE_DT_GET(DT_INST(0, raspberrypi_rp2_gpio)), 0);
irq_enable(IO_IRQ_BANK0);
return 0;
}

#define GPIO_RASPBERRYPI_INIT(idx) \
static const struct gpio_raspberrypi_config gpio_raspberrypi_##idx##_config = { \
}; \
\
static struct gpio_raspberrypi_data gpio_raspberrypi_##idx##_data; \
\
DEVICE_DT_INST_DEFINE(idx, gpio_raspberrypi_init, NULL, \
&gpio_raspberrypi_##idx##_data, \
&gpio_raspberrypi_##idx##_config, \
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
&gpio_raspberrypi_driver_api);

DT_INST_FOREACH_STATUS_OKAY(GPIO_RASPBERRYPI_INIT)
1 change: 1 addition & 0 deletions drivers/pwm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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_PWM_RASPBERRYPI pwm_raspberrypi.c)
zephyr_library_sources_ifdef(CONFIG_PWM_RV32M1_TPM pwm_rv32m1_tpm.c)
zephyr_library_sources_ifdef(CONFIG_PWM_MCUX_TPM pwm_mcux_tpm.c)
zephyr_library_sources_ifdef(CONFIG_PWM_SAM0_TCC pwm_sam0_tcc.c)
Expand Down
Loading