coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ww_ring.c File Reference
#include <console/console.h>
#include <delay.h>
#include <device/i2c_simple.h>
#include <string.h>
#include "drivers/i2c/ww_ring/ww_ring_programs.h"
Include dependency graph for ww_ring.c:

Go to the source code of this file.

Data Structures

struct  TiLp55231
 

Macros

#define WW_RING_BASE_ADDR   0x32
 
#define LP55231_ENGCTRL1_REG   0x00
 
#define LP55231_ENGCTRL2_REG   0x01
 
#define LP55231_D1_CRT_CTRL_REG   0x26
 
#define LP55231_MISC_REG   0x36
 
#define LP55231_VARIABLE_REG   0x3c
 
#define LP55231_RESET_REG   0x3d
 
#define LP55231_ENG1_PROG_START   0x4c
 
#define LP55231_PROG_PAGE_REG   0x4f
 
#define LP55231_PROG_BASE_REG   0x50
 
#define LP55231_CRT_CTRL_DEFAULT   0xaf
 
#define LP55231_ENGCTRL1_CHIP_EN   0x40
 
#define LP55231_ENGCTRL1_ALL_ENG_GO   0x2a
 
#define LP55231_ENGCTRL2_ALL_DISABLE   0
 
#define LP55231_ENGCTRL2_ALL_LOAD   0x15
 
#define LP55231_ENGCTRL2_ALL_RUN   0x2a
 
#define LP55231_MISC_AUTOINCR   (1 << 6)
 
#define LP55231_MISC_PUMP_1X   (1 << 3)
 
#define LP55231_MISC_INT_CLK   (3 << 0)
 
#define LP55231_VARIABLE_COOKIE   0xb4
 
#define LP55231_RESET_VALUE   0xff
 
#define LP55231_PROG_PAGE_SIZE   32
 
#define LP55231_PROG_PAGES   6
 
#define LP55231_MAX_PROG_SIZE   (LP55231_PROG_PAGE_SIZE * LP55231_PROG_PAGES)
 
#define LP55231_I2C_BASE_ADDR   0x32
 

Functions

static void ww_ring_init (unsigned int i2c_bus)
 
static int ledc_transfer (TiLp55231 *ledc, struct i2c_msg *segs, int seg_count, int reset)
 
static int ledc_write (TiLp55231 *ledc, uint8_t start_addr, const uint8_t *data, unsigned int count)
 
static int ledc_read (TiLp55231 *ledc, uint8_t addr, uint8_t *data)
 
static int ledc_reset (TiLp55231 *ledc)
 
static void ledc_write_program (TiLp55231 *ledc, uint8_t load_addr, const uint8_t *program, unsigned int count)
 
static void ledc_write_engctrl2 (TiLp55231 *ledc, uint8_t value)
 
static void ledc_run_program (TiLp55231 *ledc, const TiLp55231Program *program_desc)
 
static int ledc_init_validate (TiLp55231 *ledc)
 
int ww_ring_display_pattern (unsigned int i2c_bus, enum display_pattern pattern)
 

Variables

static TiLp55231 lp55231s [WW_RING_NUM_LED_CONTROLLERS]
 

Macro Definition Documentation

◆ LP55231_CRT_CTRL_DEFAULT

#define LP55231_CRT_CTRL_DEFAULT   0xaf

Definition at line 40 of file ww_ring.c.

◆ LP55231_D1_CRT_CTRL_REG

#define LP55231_D1_CRT_CTRL_REG   0x26

Definition at line 31 of file ww_ring.c.

◆ LP55231_ENG1_PROG_START

#define LP55231_ENG1_PROG_START   0x4c

Definition at line 35 of file ww_ring.c.

◆ LP55231_ENGCTRL1_ALL_ENG_GO

#define LP55231_ENGCTRL1_ALL_ENG_GO   0x2a

Definition at line 44 of file ww_ring.c.

◆ LP55231_ENGCTRL1_CHIP_EN

#define LP55231_ENGCTRL1_CHIP_EN   0x40

Definition at line 43 of file ww_ring.c.

◆ LP55231_ENGCTRL1_REG

#define LP55231_ENGCTRL1_REG   0x00

Definition at line 29 of file ww_ring.c.

◆ LP55231_ENGCTRL2_ALL_DISABLE

#define LP55231_ENGCTRL2_ALL_DISABLE   0

Definition at line 47 of file ww_ring.c.

◆ LP55231_ENGCTRL2_ALL_LOAD

#define LP55231_ENGCTRL2_ALL_LOAD   0x15

Definition at line 48 of file ww_ring.c.

◆ LP55231_ENGCTRL2_ALL_RUN

#define LP55231_ENGCTRL2_ALL_RUN   0x2a

Definition at line 49 of file ww_ring.c.

◆ LP55231_ENGCTRL2_REG

#define LP55231_ENGCTRL2_REG   0x01

Definition at line 30 of file ww_ring.c.

◆ LP55231_I2C_BASE_ADDR

#define LP55231_I2C_BASE_ADDR   0x32

Definition at line 368 of file ww_ring.c.

◆ LP55231_MAX_PROG_SIZE

#define LP55231_MAX_PROG_SIZE   (LP55231_PROG_PAGE_SIZE * LP55231_PROG_PAGES)

Definition at line 71 of file ww_ring.c.

◆ LP55231_MISC_AUTOINCR

#define LP55231_MISC_AUTOINCR   (1 << 6)

Definition at line 52 of file ww_ring.c.

◆ LP55231_MISC_INT_CLK

#define LP55231_MISC_INT_CLK   (3 << 0)

Definition at line 54 of file ww_ring.c.

◆ LP55231_MISC_PUMP_1X

#define LP55231_MISC_PUMP_1X   (1 << 3)

Definition at line 53 of file ww_ring.c.

◆ LP55231_MISC_REG

#define LP55231_MISC_REG   0x36

Definition at line 32 of file ww_ring.c.

◆ LP55231_PROG_BASE_REG

#define LP55231_PROG_BASE_REG   0x50

Definition at line 37 of file ww_ring.c.

◆ LP55231_PROG_PAGE_REG

#define LP55231_PROG_PAGE_REG   0x4f

Definition at line 36 of file ww_ring.c.

◆ LP55231_PROG_PAGE_SIZE

#define LP55231_PROG_PAGE_SIZE   32

Definition at line 69 of file ww_ring.c.

◆ LP55231_PROG_PAGES

#define LP55231_PROG_PAGES   6

Definition at line 70 of file ww_ring.c.

◆ LP55231_RESET_REG

#define LP55231_RESET_REG   0x3d

Definition at line 34 of file ww_ring.c.

◆ LP55231_RESET_VALUE

#define LP55231_RESET_VALUE   0xff

Definition at line 63 of file ww_ring.c.

◆ LP55231_VARIABLE_COOKIE

#define LP55231_VARIABLE_COOKIE   0xb4

Definition at line 60 of file ww_ring.c.

◆ LP55231_VARIABLE_REG

#define LP55231_VARIABLE_REG   0x3c

Definition at line 33 of file ww_ring.c.

◆ WW_RING_BASE_ADDR

#define WW_RING_BASE_ADDR   0x32

Definition at line 26 of file ww_ring.c.

Function Documentation

◆ ledc_init_validate()

static int ledc_init_validate ( TiLp55231 ledc)
static

◆ ledc_read()

static int ledc_read ( TiLp55231 ledc,
uint8_t  addr,
uint8_t data 
)
static

Definition at line 156 of file ww_ring.c.

References addr, ARRAY_SIZE, i2c_msg::buf, TiLp55231::dev_addr, i2c_msg::flags, I2C_M_RD, ledc_transfer(), i2c_msg::len, LP55231_RESET_REG, and i2c_msg::slave.

Referenced by ledc_init_validate(), and ledc_reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ledc_reset()

static int ledc_reset ( TiLp55231 ledc)
static

Definition at line 181 of file ww_ring.c.

References BIOS_WARNING, TiLp55231::dev_addr, ledc_read(), ledc_write(), LP55231_RESET_REG, LP55231_RESET_VALUE, and printk.

Referenced by ledc_init_validate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ledc_run_program()

◆ ledc_transfer()

static int ledc_transfer ( TiLp55231 ledc,
struct i2c_msg segs,
int  seg_count,
int  reset 
)
static

Definition at line 103 of file ww_ring.c.

References BIOS_WARNING, i2c_msg::buf, TiLp55231::i2c_bus, i2c_transfer(), printk, reset(), and i2c_msg::slave.

Referenced by ledc_read(), and ledc_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ledc_write()

static int ledc_write ( TiLp55231 ledc,
uint8_t  start_addr,
const uint8_t data,
unsigned int  count 
)
static

Definition at line 133 of file ww_ring.c.

References BIOS_WARNING, i2c_msg::buf, count, TiLp55231::data_buffer, TiLp55231::dev_addr, i2c_msg::flags, ledc_transfer(), i2c_msg::len, LP55231_RESET_REG, memcpy(), printk, and i2c_msg::slave.

Referenced by ledc_init_validate(), ledc_reset(), ledc_run_program(), ledc_write_engctrl2(), and ledc_write_program().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ledc_write_engctrl2()

static void ledc_write_engctrl2 ( TiLp55231 ledc,
uint8_t  value 
)
static

Definition at line 241 of file ww_ring.c.

References ledc_write(), LP55231_ENGCTRL2_REG, udelay(), and value.

Referenced by ledc_run_program(), and ww_ring_display_pattern().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ledc_write_program()

static void ledc_write_program ( TiLp55231 ledc,
uint8_t  load_addr,
const uint8_t program,
unsigned int  count 
)
static

Definition at line 211 of file ww_ring.c.

References BIOS_WARNING, count, ledc_write(), LP55231_MAX_PROG_SIZE, LP55231_PROG_BASE_REG, LP55231_PROG_PAGE_REG, LP55231_PROG_PAGE_SIZE, and printk.

Referenced by ledc_run_program().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ww_ring_display_pattern()

int ww_ring_display_pattern ( unsigned int  i2c_bus,
enum display_pattern  pattern 
)

Definition at line 326 of file ww_ring.c.

References BIOS_WARNING, WwRingStateProg::led_pattern, ledc_run_program(), ledc_write_engctrl2(), LP55231_ENGCTRL2_ALL_DISABLE, lp55231s, pattern, printk, WwRingStateProg::programs, ww_ring_init(), WW_RING_NUM_LED_CONTROLLERS, and wwr_state_programs.

Referenced by display_pattern().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ww_ring_init()

static void ww_ring_init ( unsigned int  i2c_bus)
static

Definition at line 370 of file ww_ring.c.

References BIOS_INFO, BIOS_WARNING, count, TiLp55231::dev_addr, TiLp55231::i2c_bus, i2c_bus, ledc_init_validate(), LP55231_I2C_BASE_ADDR, lp55231s, printk, and WW_RING_NUM_LED_CONTROLLERS.

Referenced by ww_ring_display_pattern().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ lp55231s

Definition at line 88 of file ww_ring.c.

Referenced by ww_ring_display_pattern(), and ww_ring_init().