diff options
author | Marcel Ziswiler <marcel.ziswiler@toradex.com> | 2016-06-06 16:54:42 +0200 |
---|---|---|
committer | Marcel Ziswiler <marcel.ziswiler@toradex.com> | 2016-06-29 16:49:35 +0200 |
commit | eeb6061f4b93cdd2c946e354ff69224163636282 (patch) | |
tree | c0332fd3e31f147d1141fa0f982ef54ae8b87d4f /arch/arm/mach-tegra/board-apalis-tk1-sysedp.c | |
parent | 4d58a5bc83475c1ca5f9990cf9bfeba5b2fe3bbc (diff) |
arm: tegra: initial support for apalis tk1Apalis_TK1_LinuxImageV2.6Beta2_20160701
This patch adds support for the Toradex Apalis TK1 acomputer on module
which can be used on different carrier boards.
The module consists of a Tegra TK1 SoC, a PMIC solution, 2 GB of DDR3L
RAM, a bunch of level shifters, an eMMC, a TMP451 temperature sensor
chip, an I210 gigabit Ethernet controller and a SGTL5000 audio codec.
Furthermore, there is a Kinetis MK20DN512 companion micro controller for
analogue, CAN and resistive touch functionality which is not yet
supported.
This is known to boot into either a basic Angstrom/OpenEmbedded/Yocto
or L4T/JetPack Ubuntu based image.
The following things are known to work to a certain extend:
- analogue/digital audio
- debug UART1
- DVFS power management incl. low power core migration
- eMMC
- gigabit Ethernet
- GPIOs
- HDMI (incl. HDA audio)
- I2C
- LVDS
- PCIe
- SATA
- SD/MMC cards
- temperature sensor
- USB host ports
The rest is untested.
Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Acked-by: Dominik Sliwa <dominik.sliwa@toradex.com>
Diffstat (limited to 'arch/arm/mach-tegra/board-apalis-tk1-sysedp.c')
-rw-r--r-- | arch/arm/mach-tegra/board-apalis-tk1-sysedp.c | 193 |
1 files changed, 193 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/board-apalis-tk1-sysedp.c b/arch/arm/mach-tegra/board-apalis-tk1-sysedp.c new file mode 100644 index 000000000000..298440457afe --- /dev/null +++ b/arch/arm/mach-tegra/board-apalis-tk1-sysedp.c @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2016 Toradex AG. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <linux/sysedp.h> +#include <linux/platform_device.h> +#include <linux/platform_data/tegra_edp.h> +#include <linux/power_supply.h> +#include <mach/edp.h> +#include "board.h" +#include "board-panel.h" + +/* --- EDP consumers data --- */ +/* TODO static unsigned int ov5693_states[] = { 0, 300 };*/ +static unsigned int mt9m114_states[] = { 0, 150 }; +static unsigned int sdhci_states[] = { 0, 966 }; +static unsigned int speaker_states[] = { 0, 1080 }; +static unsigned int wifi_states[] = { 0, 3070 }; + +/* 10 inch panel */ +static unsigned int pwm_backlight_states[] = { + 0, 425, 851, 1276, 1702, 2127, 2553, 2978, 3404, 3829, 4255 +}; + +/* TODO +static unsigned int as364x_states[] = { + 0, 350, 700, 1050, 1400, 1750, 2100, 2450, 2800, 3150, 3500 +}; +*/ + +static struct sysedp_consumer_data apalis_tk1_sysedp_consumer_data[] = { + /* TODO SYSEDP_CONSUMER_DATA("ov5693", ov5693_states), */ + SYSEDP_CONSUMER_DATA("mt9m114", mt9m114_states), + SYSEDP_CONSUMER_DATA("speaker", speaker_states), + SYSEDP_CONSUMER_DATA("wifi", wifi_states), + SYSEDP_CONSUMER_DATA("pwm-backlight", pwm_backlight_states), + SYSEDP_CONSUMER_DATA("sdhci-tegra.2", sdhci_states), + SYSEDP_CONSUMER_DATA("sdhci-tegra.3", sdhci_states), + /* TODO SYSEDP_CONSUMER_DATA("as364x", as364x_states), */ +}; + +static struct sysedp_platform_data apalis_tk1_sysedp_platform_data = { + .consumer_data = apalis_tk1_sysedp_consumer_data, + .consumer_data_size = ARRAY_SIZE(apalis_tk1_sysedp_consumer_data), + .margin = 0, +}; + +static struct platform_device apalis_tk1_sysedp_device = { + .name = "sysedp", + .id = -1, + .dev = {.platform_data = &apalis_tk1_sysedp_platform_data} +}; + +void __init apalis_tk1_new_sysedp_init(void) +{ + int r; + + r = platform_device_register(&apalis_tk1_sysedp_device); + WARN_ON(r); +} + +/* --- Battery monitor data --- */ +static struct sysedp_batmon_ibat_lut apalis_tk1_ibat_lut[] = { +/*-- temp in deci-C, current in milli ampere --*/ + {600, 9750}, + {-300, 9750} +}; + +/* Values for Leyden HY-LDN-N-TD battery */ +/* 45C 23C 10C 5C 0C -20 */ +static int rbat_data[] = { + 100000, 120000, 140000, 170000, 190000, 210000, /* 100% */ + 100000, 120000, 150000, 170000, 190000, 210000, /* 55% */ + 100000, 130000, 150000, 170000, 200000, 210000, /* 50% */ + 110000, 130000, 160000, 170000, 200000, 210000, /* 10% */ + 120000, 140000, 170000, 180000, 210000, 220000, /* 0% */ +}; +static int rbat_temp_axis[] = { 45, 23, 10, 5, 0, -20 }; +static int rbat_capacity_axis[] = { 100, 55, 50, 10, 0 }; + +struct sysedp_batmon_rbat_lut apalis_tk1_rbat_lut = { + .temp_axis = rbat_temp_axis, + .temp_size = ARRAY_SIZE(rbat_temp_axis), + .capacity_axis = rbat_capacity_axis, + .capacity_size = ARRAY_SIZE(rbat_capacity_axis), + .data = rbat_data, + .data_size = ARRAY_SIZE(rbat_data), +}; + +/* Fuel Gauge is BQ20z45 (SBS battery) */ +static struct sysedp_batmon_ocv_lut apalis_tk1_ocv_lut[] = { + /*SOC, OCV in micro volt */ + {100, 8372010}, + {95, 8163880}, + {90, 8069280}, + {85, 7970700}, + {80, 7894100}, + {75, 7820860}, + {70, 7751890}, + {65, 7691770}, + {60, 7641110}, + {55, 7598990}, + {50, 7564200}, + {45, 7534290}, + {40, 7511410}, + {35, 7491870}, + {30, 7468380}, + {25, 7435720}, + {20, 7388720}, + {15, 7338370}, + {10, 7219650}, + {0, 5999850}, +}; + +static struct sysedp_batmon_calc_platform_data apalis_tk1_batmon_pdata = { + .power_supply = "sbs-battery", + .r_const = 70000, /* in micro ohm */ + .vsys_min = 5880000, /* in micro volt */ + .ibat_lut = apalis_tk1_ibat_lut, + .rbat_lut = &apalis_tk1_rbat_lut, + .ocv_lut = apalis_tk1_ocv_lut, +}; + +static struct platform_device apalis_tk1_batmon_device = { + .name = "sysedp_batmon_calc", + .id = -1, + .dev = {.platform_data = &apalis_tk1_batmon_pdata} +}; + +void __init apalis_tk1_sysedp_batmon_init(void) +{ + int r; + + if (get_power_supply_type() != POWER_SUPPLY_TYPE_BATTERY) { + /* modify platform data on-the-fly to enable virtual battery */ + apalis_tk1_batmon_pdata.power_supply = "test_battery"; + apalis_tk1_batmon_pdata.update_interval = 2000; + } + + r = platform_device_register(&apalis_tk1_batmon_device); + WARN_ON(r); +} + +static struct tegra_sysedp_platform_data + apalis_tk1_sysedp_dynamic_capping_platdata = { + .core_gain = 100, + .init_req_watts = 20000, +}; + +static struct platform_device apalis_tk1_sysedp_dynamic_capping = { + .name = "sysedp_dynamic_capping", + .id = -1, + .dev = {.platform_data = &apalis_tk1_sysedp_dynamic_capping_platdata} +}; + +void __init apalis_tk1_sysedp_dynamic_capping_init(void) +{ + int r; + struct tegra_sysedp_corecap *corecap; + unsigned int corecap_size; + + corecap = tegra_get_sysedp_corecap(&corecap_size); + if (!corecap) { + WARN_ON(1); + return; + } + apalis_tk1_sysedp_dynamic_capping_platdata.corecap = corecap; + apalis_tk1_sysedp_dynamic_capping_platdata.corecap_size = corecap_size; + + apalis_tk1_sysedp_dynamic_capping_platdata.cpufreq_lim = + tegra_get_system_edp_entries + (&apalis_tk1_sysedp_dynamic_capping_platdata.cpufreq_lim_size); + if (!apalis_tk1_sysedp_dynamic_capping_platdata.cpufreq_lim) { + WARN_ON(1); + return; + } + + r = platform_device_register(&apalis_tk1_sysedp_dynamic_capping); + WARN_ON(r); +} |