pru: BeagleBone Firmware upgrade to Debian 11.7 Bullseye (#6577)
* Porting BeagleBone to Kernel 5.10 * Fixing issue with installation for BeagleBone. This fix resolve 2 issue: 1. Conflict with AVR packages. 2. "klipper_pru" script is executed before PRU cores are ready * Adding additional steps to BeagleBone install guide. * Updating BeagleBone documentation, adding different use cases, adding buses configurations SPI, I2C, CAN, UART Signed-off-by: Oleg Gavavka <work@datalink.net.ua>
This commit is contained in:
135
src/pru/pru0.c
135
src/pru/pru0.c
@@ -8,17 +8,16 @@
|
||||
#include <stdint.h> // uint32_t
|
||||
#include <string.h> // memset
|
||||
#include <pru/io.h> // write_r31
|
||||
#include <pru_cfg.h> // CT_CFG
|
||||
#include <pru_intc.h> // CT_INTC
|
||||
#include <pru_rpmsg.h> // pru_rpmsg_send
|
||||
#include <pru_virtio_ids.h> // VIRTIO_ID_RPMSG
|
||||
#include <rsc_types.h> // resource_table
|
||||
#include "board/io.h" // readl
|
||||
#include "board/misc.h" // console_sendf
|
||||
#include "command.h" // command_encode_add_frame
|
||||
#include "compiler.h" // __section
|
||||
#include "internal.h" // SHARED_MEM
|
||||
#include "sched.h" // sched_shutdown
|
||||
#include "intc_map_0.h"
|
||||
#include "resource_table.h"
|
||||
|
||||
struct pru_rpmsg_transport transport;
|
||||
static uint16_t transport_dst;
|
||||
@@ -32,8 +31,7 @@ static uint16_t transport_dst;
|
||||
#define CHAN_DESC "Channel 30"
|
||||
#define CHAN_PORT 30
|
||||
|
||||
#define RPMSG_HDR_SIZE 16
|
||||
static uint8_t transmit_buf[RPMSG_BUF_SIZE - RPMSG_HDR_SIZE];
|
||||
static uint8_t transmit_buf[RPMSG_MESSAGE_SIZE];
|
||||
static int transmit_pos;
|
||||
|
||||
// Transmit all pending message blocks
|
||||
@@ -195,7 +193,7 @@ static void
|
||||
process_io(void)
|
||||
{
|
||||
for (;;) {
|
||||
CT_INTC.SECR0 = ((1 << KICK_PRU0_FROM_ARM_EVENT)
|
||||
PRU_INTC.SECR0 = ((1 << KICK_PRU0_FROM_ARM_EVENT)
|
||||
| (1 << KICK_PRU0_EVENT));
|
||||
check_can_send();
|
||||
int can_sleep = check_can_read();
|
||||
@@ -251,112 +249,6 @@ console_sendf(const struct command_encoder *ce, va_list args)
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Resource table
|
||||
****************************************************************/
|
||||
|
||||
/*
|
||||
* Sizes of the virtqueues (expressed in number of buffers supported,
|
||||
* and must be power of 2)
|
||||
*/
|
||||
#define PRU_RPMSG_VQ0_SIZE 16
|
||||
#define PRU_RPMSG_VQ1_SIZE 16
|
||||
|
||||
/*
|
||||
* The feature bitmap for virtio rpmsg
|
||||
*/
|
||||
#define VIRTIO_RPMSG_F_NS 0 //name service notifications
|
||||
|
||||
/* This firmware supports name service notifications as one of its features */
|
||||
#define RPMSG_PRU_C0_FEATURES (1 << VIRTIO_RPMSG_F_NS)
|
||||
|
||||
/* Definition for unused interrupts */
|
||||
#define HOST_UNUSED 255
|
||||
|
||||
/* Mapping sysevts to a channel. Each pair contains a sysevt, channel. */
|
||||
static struct ch_map pru_intc_map[] = {
|
||||
{IEP_EVENT, WAKE_PRU1_IRQ},
|
||||
{KICK_ARM_EVENT, WAKE_ARM_IRQ},
|
||||
{KICK_PRU0_FROM_ARM_EVENT, WAKE_PRU0_IRQ},
|
||||
{KICK_PRU0_EVENT, WAKE_PRU0_IRQ},
|
||||
{KICK_PRU1_EVENT, WAKE_PRU1_IRQ},
|
||||
};
|
||||
|
||||
struct my_resource_table {
|
||||
struct resource_table base;
|
||||
|
||||
uint32_t offset[2]; /* Should match 'num' in actual definition */
|
||||
|
||||
/* rpmsg vdev entry */
|
||||
struct fw_rsc_vdev rpmsg_vdev;
|
||||
struct fw_rsc_vdev_vring rpmsg_vring0;
|
||||
struct fw_rsc_vdev_vring rpmsg_vring1;
|
||||
|
||||
/* intc definition */
|
||||
struct fw_rsc_custom pru_ints;
|
||||
} resourceTable __section(".resource_table") = {
|
||||
{
|
||||
1, /* Resource table version: only version 1 is
|
||||
* supported by the current driver */
|
||||
2, /* number of entries in the table */
|
||||
{ 0, 0 }, /* reserved, must be zero */
|
||||
},
|
||||
/* offsets to entries */
|
||||
{
|
||||
offsetof(struct my_resource_table, rpmsg_vdev),
|
||||
offsetof(struct my_resource_table, pru_ints),
|
||||
},
|
||||
|
||||
/* rpmsg vdev entry */
|
||||
{
|
||||
(uint32_t)TYPE_VDEV, //type
|
||||
(uint32_t)VIRTIO_ID_RPMSG, //id
|
||||
(uint32_t)0, //notifyid
|
||||
(uint32_t)RPMSG_PRU_C0_FEATURES,//dfeatures
|
||||
(uint32_t)0, //gfeatures
|
||||
(uint32_t)0, //config_len
|
||||
(uint8_t)0, //status
|
||||
(uint8_t)2, //num_of_vrings, only two is supported
|
||||
{(uint8_t)0, (uint8_t)0 }, //reserved
|
||||
/* no config data */
|
||||
},
|
||||
/* the two vrings */
|
||||
{
|
||||
0, //da, will be populated by host, can't pass it in
|
||||
16, //align (bytes),
|
||||
PRU_RPMSG_VQ0_SIZE, //num of descriptors
|
||||
0, //notifyid, will be populated, can't pass right now
|
||||
0 //reserved
|
||||
},
|
||||
{
|
||||
0, //da, will be populated by host, can't pass it in
|
||||
16, //align (bytes),
|
||||
PRU_RPMSG_VQ1_SIZE, //num of descriptors
|
||||
0, //notifyid, will be populated, can't pass right now
|
||||
0 //reserved
|
||||
},
|
||||
|
||||
{
|
||||
TYPE_CUSTOM, TYPE_PRU_INTS,
|
||||
sizeof(struct fw_rsc_custom_ints),
|
||||
{ /* PRU_INTS version */
|
||||
{
|
||||
0x0000,
|
||||
/* Channel-to-host mapping, 255 for unused */
|
||||
{
|
||||
WAKE_PRU0_IRQ, WAKE_PRU1_IRQ, WAKE_ARM_IRQ,
|
||||
HOST_UNUSED, HOST_UNUSED, HOST_UNUSED,
|
||||
HOST_UNUSED, HOST_UNUSED, HOST_UNUSED, HOST_UNUSED
|
||||
},
|
||||
/* Number of evts being mapped to channels */
|
||||
(sizeof(pru_intc_map) / sizeof(struct ch_map)),
|
||||
/* Pointer to the structure containing mapped events */
|
||||
pru_intc_map,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Startup
|
||||
@@ -368,11 +260,26 @@ int
|
||||
main(void)
|
||||
{
|
||||
// allow access to external memory
|
||||
#if defined(__AM335X__)
|
||||
/* AM335x must enable OCP master port access in order for the PRU to
|
||||
* read external memories.*/
|
||||
CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
|
||||
#endif
|
||||
|
||||
/* Clear the status of the PRU-ICSS system event that the ARM
|
||||
will use to 'kick' us */
|
||||
#if defined(__AM335X__)
|
||||
PRU_INTC.SICR_bit.STS_CLR_IDX = KICK_PRU0_FROM_ARM_EVENT;
|
||||
#elif defined(__TDA4VM__) || defined(__AM62X__)
|
||||
PRU_INTC.STATUS_CLR_INDEX_REG_bit.STATUS_CLR_INDEX = \
|
||||
KICK_PRU0_FROM_ARM_EVENT;
|
||||
#else
|
||||
#error "Unsupported SoC."
|
||||
#endif
|
||||
|
||||
// clear all irqs
|
||||
CT_INTC.SECR0 = 0xffffffff;
|
||||
CT_INTC.SECR1 = 0xffffffff;
|
||||
PRU_INTC.SECR0 = 0xffffffff;
|
||||
PRU_INTC.SECR1 = 0xffffffff;
|
||||
|
||||
/* Make sure the Linux drivers are ready for RPMsg communication */
|
||||
volatile uint8_t *status = &resourceTable.rpmsg_vdev.status;
|
||||
|
||||
Reference in New Issue
Block a user