Skip to content

Commit 8709e3a

Browse files
Update bdk to hekate 5.5.2
1 parent f730f4a commit 8709e3a

52 files changed

Lines changed: 1534 additions & 715 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bdk/gfx/di.c renamed to bdk/display/di.c

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "di.h"
2121
#include <power/max77620.h>
2222
#include <power/max7762x.h>
23+
#include <mem/heap.h>
2324
#include <soc/clock.h>
2425
#include <soc/gpio.h>
2526
#include <soc/hw_init.h>
@@ -170,9 +171,9 @@ int display_dsi_read(u8 cmd, u32 len, void *data, bool video_enabled)
170171

171172
void display_dsi_write(u8 cmd, u32 len, void *data, bool video_enabled)
172173
{
174+
u8 *fifo8;
175+
u32 *fifo32;
173176
u32 host_control;
174-
u32 fifo32[DSI_STATUS_RX_FIFO_SIZE] = {0};
175-
u8 *fifo8 = (u8 *)fifo32;
176177

177178
// Enable host cmd packets during video and save host control.
178179
if (video_enabled)
@@ -193,13 +194,16 @@ void display_dsi_write(u8 cmd, u32 len, void *data, bool video_enabled)
193194
break;
194195

195196
default:
197+
fifo32 = calloc(DSI_STATUS_RX_FIFO_SIZE * 8, 4);
198+
fifo8 = (u8 *)fifo32;
196199
fifo32[0] = (len << 8) | MIPI_DSI_DCS_LONG_WRITE;
197200
fifo8[4] = cmd;
198201
memcpy(&fifo8[5], data, len);
199202
len += 4 + 1; // Increase length by CMD/length word and DCS CMD.
200203
for (u32 i = 0; i < (ALIGN(len, 4) / 4); i++)
201204
DSI(_DSIREG(DSI_WR_DATA)) = fifo32[i];
202205
DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
206+
free(fifo32);
203207
break;
204208
}
205209

@@ -215,29 +219,30 @@ void display_dsi_write(u8 cmd, u32 len, void *data, bool video_enabled)
215219
void display_init()
216220
{
217221
// Check if display is already initialized.
218-
if (CLOCK(CLK_RST_CONTROLLER_CLK_ENB_L_SET) & BIT(CLK_L_DISP1))
222+
if (CLOCK(CLK_RST_CONTROLLER_CLK_OUT_ENB_L) & BIT(CLK_L_DISP1))
219223
_display_panel_and_hw_end(true);
220224

221225
// Get Chip ID.
222226
bool tegra_t210 = hw_get_chip_id() == GP_HIDREV_MAJOR_T210;
223227

224-
// T210B01: Power on SD2 regulator for supplying LD0.
228+
// T210B01: Power on SD2 regulator for supplying LDO0.
225229
if (!tegra_t210)
226230
{
227231
// Set SD2 regulator voltage.
228-
max77620_regulator_set_voltage(REGULATOR_SD2, 1325000);
232+
max7762x_regulator_set_voltage(REGULATOR_SD2, 1325000);
229233

230234
// Set slew rate and enable SD2 regulator.
231235
i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_SD2_CFG, (1 << MAX77620_SD_SR_SHIFT) | MAX77620_SD_CFG1_FSRADE_SD_ENABLE);
232-
max77620_regulator_enable(REGULATOR_SD2, 1);
236+
max7762x_regulator_enable(REGULATOR_SD2, true);
233237

234238
}
235239

236240
// Enable power to display panel controller.
237-
max77620_regulator_set_volt_and_flags(REGULATOR_LDO0, 1200000, MAX77620_POWER_MODE_NORMAL); // Configure to 1.2V.
241+
max7762x_regulator_set_voltage(REGULATOR_LDO0, 1200000);
242+
max7762x_regulator_enable(REGULATOR_LDO0, true);
243+
238244
if (tegra_t210)
239-
i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_GPIO7,
240-
MAX77620_CNFG_GPIO_OUTPUT_VAL_HIGH | MAX77620_CNFG_GPIO_DRV_PUSHPULL); // T210: LD0 -> GPIO7 -> Display panel.
245+
max77620_config_gpio(7, MAX77620_GPIO_OUTPUT_ENABLE); // T210: LD0 -> GPIO7 -> Display panel.
241246

242247
// Enable Display Interface specific clocks.
243248
CLOCK(CLK_RST_CONTROLLER_RST_DEV_H_CLR) = BIT(CLK_H_MIPI_CAL) | BIT(CLK_H_DSI);
@@ -293,7 +298,7 @@ void display_init()
293298

294299
// Set DISP1 clock source and parent clock.
295300
CLOCK(CLK_RST_CONTROLLER_CLK_SOURCE_DISP1) = 0x40000000; // PLLD_OUT.
296-
u32 plld_div = (3 << 20) | (20 << 11) | 1; // DIVM: 1, DIVN: 20, DIVP: 3. PLLD_OUT: 768 MHz, PLLD_OUT0 (DSI): 96 MHz.
301+
u32 plld_div = (3 << 20) | (20 << 11) | 1; // DIVM: 1, DIVN: 20, DIVP: 3. PLLD_OUT: 768 MHz, PLLD_OUT0 (DSI): 97.5 MHz (offset).
297302
CLOCK(CLK_RST_CONTROLLER_PLLD_BASE) = PLLCX_BASE_ENABLE | PLLCX_BASE_LOCK | plld_div;
298303

299304
if (tegra_t210)
@@ -335,9 +340,12 @@ void display_init()
335340

336341
#if 0
337342
// Get Display ID.
338-
_display_id = 0xCCCCCC;
343+
_display_id = 0xCCCCCC; // Set initial value. 4th byte cleared.
339344
display_dsi_read(MIPI_DCS_GET_DISPLAY_ID, 3, &_display_id, DSI_VIDEO_DISABLED);
340345
#else
346+
// Drain RX FIFO.
347+
_display_dsi_read_rx_fifo(NULL);
348+
341349
// Set reply size.
342350
_display_dsi_send_cmd(MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, 3, 0);
343351
_display_dsi_wait(250000, _DSIREG(DSI_TRIGGER), DSI_TRIGGER_HOST | DSI_TRIGGER_VIDEO);
@@ -407,11 +415,11 @@ void display_init()
407415
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_SET_DISPLAY_ON, 20000);
408416

409417
// Configure PLLD for DISP1.
410-
plld_div = (1 << 20) | (24 << 11) | 1; // DIVM: 1, DIVN: 24, DIVP: 1. PLLD_OUT: 768 MHz, PLLD_OUT0 (DSI): 230.4 MHz.
418+
plld_div = (1 << 20) | (24 << 11) | 1; // DIVM: 1, DIVN: 24, DIVP: 1. PLLD_OUT: 768 MHz, PLLD_OUT0 (DSI): 234 MHz (offset).
411419
CLOCK(CLK_RST_CONTROLLER_PLLD_BASE) = PLLCX_BASE_ENABLE | PLLCX_BASE_LOCK | plld_div;
412420

413421
if (tegra_t210)
414-
CLOCK(CLK_RST_CONTROLLER_PLLD_MISC1) = 0x20; // PLLD_SETUP
422+
CLOCK(CLK_RST_CONTROLLER_PLLD_MISC1) = 0x20; // PLLD_SETUP.
415423
else
416424
CLOCK(CLK_RST_CONTROLLER_PLLD_MISC1) = 0;
417425
CLOCK(CLK_RST_CONTROLLER_PLLD_MISC) = 0x2DFC00; // Use new PLLD_SDM_DIN.
@@ -420,7 +428,7 @@ void display_init()
420428
DSI(_DSIREG(DSI_PAD_CONTROL_1)) = 0;
421429
DSI(_DSIREG(DSI_PHY_TIMING_0)) = tegra_t210 ? 0x6070601 : 0x6070603;
422430
exec_cfg((u32 *)DSI_BASE, _display_dsi_packet_config, 19);
423-
// Set pixel clock dividers: 230.4 / 3 / 1 = 76.8 MHz. 60 Hz.
431+
// Set pixel clock dividers: 234 / 3 / 1 = 78 MHz (offset) for 60 Hz.
424432
DISPLAY_A(_DIREG(DC_DISP_DISP_CLOCK_CONTROL)) = PIXEL_CLK_DIVIDER_PCD1 | SHIFT_CLK_DIVIDER(4); // 4: div3.
425433
exec_cfg((u32 *)DSI_BASE, _display_dsi_mode_config, 10);
426434
usleep(10000);
@@ -600,11 +608,20 @@ static void _display_panel_and_hw_end(bool no_panel_deinit)
600608

601609
void display_end() { _display_panel_and_hw_end(false); };
602610

603-
u16 display_get_decoded_lcd_id()
611+
u16 display_get_decoded_panel_id()
604612
{
605613
return _display_id;
606614
}
607615

616+
void display_set_decoded_panel_id(u32 id)
617+
{
618+
// Decode Display ID.
619+
_display_id = ((id >> 8) & 0xFF00) | (id & 0xFF);
620+
621+
if ((_display_id & 0xFF) == PANEL_JDI_XXX062M)
622+
_display_id = PANEL_JDI_XXX062M;
623+
}
624+
608625
void display_color_screen(u32 color)
609626
{
610627
exec_cfg((u32 *)DISPLAY_A_BASE, cfg_display_one_color, 8);

bdk/gfx/di.h renamed to bdk/display/di.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@
651651
* [10] 96 [09]: JDI LAM062M109A
652652
* [20] 93 [0F]: InnoLux P062CCA-AZ1 (Rev A1)
653653
* [20] 95 [0F]: InnoLux P062CCA-AZ2
654+
* [20] 96 [0F]: InnoLux P062CCA-AZ3
654655
* [30] 94 [0F]: AUO A062TAN01 (59.06A33.001)
655656
* [30] 95 [0F]: AUO A062TAN02 (59.06A33.002)
656657
*
@@ -671,10 +672,12 @@
671672
* 20h: InnoLux Corporation
672673
* 30h: AU Optronics
673674
* 40h: Unknown1
675+
* 50h: Unknown2 (OLED? Samsung? LG?)
674676
*
675677
* Boards, Panel Size:
676678
* 0Fh: Icosa/Iowa, 6.2"
677679
* 10h: Hoag, 5.5"
680+
* 20h: Unknown, x.x"
678681
*/
679682

680683
enum
@@ -693,8 +696,9 @@ void display_init();
693696
void display_backlight_pwm_init();
694697
void display_end();
695698

696-
/*! Get Display panel ID. */
697-
u16 display_get_decoded_lcd_id();
699+
/*! Get/Set Display panel ID. */
700+
u16 display_get_decoded_panel_id();
701+
void display_set_decoded_panel_id(u32 id);
698702

699703
/*! Show one single color on the display. */
700704
void display_color_screen(u32 color);
File renamed without changes.

bdk/input/als.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818

1919
#include "als.h"
20-
#include <power/max77620.h>
2120
#include <power/max7762x.h>
2221
#include <soc/clock.h>
2322
#include <soc/i2c.h>
@@ -98,14 +97,16 @@ void get_als_lux(als_table_t *als_val)
9897

9998
u8 als_init(als_table_t *als_val)
10099
{
100+
// Enable power to ALS IC.
101+
max7762x_regulator_set_voltage(REGULATOR_LDO6, 2900000);
102+
max7762x_regulator_enable(REGULATOR_LDO6, true);
103+
104+
// Init I2C2.
101105
pinmux_config_i2c(I2C_2);
102106
clock_enable_i2c(I2C_2);
103107
i2c_init(I2C_2);
104108

105-
max77620_regulator_set_volt_and_flags(REGULATOR_LDO6, 2900000, MAX77620_POWER_MODE_NORMAL);
106-
i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_LDO6_CFG2,
107-
(MAX77620_POWER_MODE_NORMAL << MAX77620_LDO_POWER_MODE_SHIFT | (3 << 3) | MAX77620_LDO_CFG2_ADE_ENABLE));
108-
109+
// Initialize ALS.
109110
u8 id = i2c_recv_byte(I2C_2, BH1730_I2C_ADDR, BH1730_ADDR(0x12));
110111
i2c_send_byte(I2C_2, BH1730_I2C_ADDR, BH1730_SPEC(BH1730_SPECCMD_RESET), 0);
111112
i2c_send_byte(I2C_2, BH1730_I2C_ADDR, BH1730_ADDR(BH1730_GAIN_REG), HOS_GAIN);

0 commit comments

Comments
 (0)