Angel Pons | 47f26db | 2020-04-05 13:22:34 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 2 | |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 3 | #include <device/device.h> |
Shawn Nematbakhsh | 9547f8d | 2013-11-08 17:23:26 -0800 | [diff] [blame] | 4 | #include <smbios.h> |
Aaron Durbin | 063c873 | 2013-10-28 11:24:53 -0500 | [diff] [blame] | 5 | #include "ec.h" |
Matt DeVillier | ce0a564 | 2017-01-12 12:19:21 -0600 | [diff] [blame] | 6 | #include <variant/onboard.h> |
Julius Werner | 18ea2d3 | 2014-10-07 16:42:17 -0700 | [diff] [blame] | 7 | #include <soc/gpio.h> |
Angel Pons | 4cedb8c | 2021-05-17 18:46:41 +0200 | [diff] [blame] | 8 | #include <soc/int15.h> |
Kein Yuan | 704c006 | 2014-05-01 20:20:06 -0700 | [diff] [blame] | 9 | #include <bootstate.h> |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 10 | |
Elyes HAOUAS | d129d43 | 2018-05-04 20:23:33 +0200 | [diff] [blame] | 11 | static void mainboard_init(struct device *dev) |
Aaron Durbin | 063c873 | 2013-10-28 11:24:53 -0500 | [diff] [blame] | 12 | { |
| 13 | mainboard_ec_init(); |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 14 | #if CONFIG(BOARD_GOOGLE_NINJA) || CONFIG(BOARD_GOOGLE_SUMO) |
Matt DeVillier | ce0a564 | 2017-01-12 12:19:21 -0600 | [diff] [blame] | 15 | lan_init(); |
| 16 | #endif |
Aaron Durbin | 063c873 | 2013-10-28 11:24:53 -0500 | [diff] [blame] | 17 | } |
| 18 | |
Elyes HAOUAS | d129d43 | 2018-05-04 20:23:33 +0200 | [diff] [blame] | 19 | static int mainboard_smbios_data(struct device *dev, int *handle, |
Shawn Nematbakhsh | 9547f8d | 2013-11-08 17:23:26 -0800 | [diff] [blame] | 20 | unsigned long *current) |
| 21 | { |
| 22 | int len = 0; |
Matt DeVillier | ce0a564 | 2017-01-12 12:19:21 -0600 | [diff] [blame] | 23 | #ifdef BOARD_TRACKPAD_NAME |
Shawn Nematbakhsh | 9547f8d | 2013-11-08 17:23:26 -0800 | [diff] [blame] | 24 | len += smbios_write_type41( |
| 25 | current, handle, |
| 26 | BOARD_TRACKPAD_NAME, /* name */ |
| 27 | BOARD_TRACKPAD_IRQ, /* instance */ |
| 28 | BOARD_TRACKPAD_I2C_BUS, /* segment */ |
| 29 | BOARD_TRACKPAD_I2C_ADDR, /* bus */ |
| 30 | 0, /* device */ |
Christian Walter | e6afab1 | 2019-05-21 17:22:49 +0200 | [diff] [blame] | 31 | 0, /* function */ |
| 32 | SMBIOS_DEVICE_TYPE_OTHER); /* device type */ |
Matt DeVillier | ce0a564 | 2017-01-12 12:19:21 -0600 | [diff] [blame] | 33 | #endif |
| 34 | #ifdef BOARD_TOUCHSCREEN_NAME |
Shawn Nematbakhsh | 9547f8d | 2013-11-08 17:23:26 -0800 | [diff] [blame] | 35 | len += smbios_write_type41( |
| 36 | current, handle, |
| 37 | BOARD_TOUCHSCREEN_NAME, /* name */ |
| 38 | BOARD_TOUCHSCREEN_IRQ, /* instance */ |
| 39 | BOARD_TOUCHSCREEN_I2C_BUS, /* segment */ |
| 40 | BOARD_TOUCHSCREEN_I2C_ADDR, /* bus */ |
| 41 | 0, /* device */ |
Christian Walter | e6afab1 | 2019-05-21 17:22:49 +0200 | [diff] [blame] | 42 | 0, /* function */ |
| 43 | SMBIOS_DEVICE_TYPE_OTHER); /* device type */ |
Matt DeVillier | ce0a564 | 2017-01-12 12:19:21 -0600 | [diff] [blame] | 44 | #endif |
Shawn Nematbakhsh | 9547f8d | 2013-11-08 17:23:26 -0800 | [diff] [blame] | 45 | return len; |
| 46 | } |
| 47 | |
Elyes HAOUAS | d129d43 | 2018-05-04 20:23:33 +0200 | [diff] [blame] | 48 | static void mainboard_enable(struct device *dev) |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 49 | { |
Aaron Durbin | 063c873 | 2013-10-28 11:24:53 -0500 | [diff] [blame] | 50 | dev->ops->init = mainboard_init; |
Shawn Nematbakhsh | 9547f8d | 2013-11-08 17:23:26 -0800 | [diff] [blame] | 51 | dev->ops->get_smbios_data = mainboard_smbios_data; |
Angel Pons | 4cedb8c | 2021-05-17 18:46:41 +0200 | [diff] [blame] | 52 | |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 53 | /* Install custom int15 handler for VGA OPROM */ |
Angel Pons | 4cedb8c | 2021-05-17 18:46:41 +0200 | [diff] [blame] | 54 | if (CONFIG(VGA_ROM_RUN)) |
| 55 | install_baytrail_vga_int15_handler(); |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | struct chip_operations mainboard_ops = { |
| 59 | .enable_dev = mainboard_enable, |
| 60 | }; |
Kein Yuan | 704c006 | 2014-05-01 20:20:06 -0700 | [diff] [blame] | 61 | |
| 62 | static void edp_vdden_cb(void *unused) |
| 63 | { |
| 64 | ncore_select_func(SOC_DDI1_VDDEN_PAD, PAD_FUNC2); |
| 65 | } |
| 66 | |
Aaron Durbin | 9ef9d85 | 2015-03-16 17:30:09 -0500 | [diff] [blame] | 67 | BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_EXIT, edp_vdden_cb, NULL); |