Mainline:Broadcom Kona/Adding a new device: Difference between revisions

No edit summary
 
(One intermediate revision by the same user not shown)
Line 75: Line 75:


* The defconfig is in <code>arch/arm/configs</code>; if you got a CyanogenMod/LineageOS kernel, look for a <code>cyanogenmod_XXX_defconfig</code>; otherwise, there should be a config with a name like <code>bcmXXXXX_codename_revXX_defconfig</code> (pick the highest revision number).
* The defconfig is in <code>arch/arm/configs</code>; if you got a CyanogenMod/LineageOS kernel, look for a <code>cyanogenmod_XXX_defconfig</code>; otherwise, there should be a config with a name like <code>bcmXXXXX_codename_revXX_defconfig</code> (pick the highest revision number).
* The board config is in <code>arch/arm/mach-PLATFORM/board-ss_CODENAME.c</code> (or just <code>board-CODENAME.c</code>), where PLATFORM is <code>capri</code> for BCM218xx, <code>rhea</code> for BCM21654, <code>hawaii</code> for BCM21664 and <code>java</code> for BCM23550.
* The board file is in <code>arch/arm/mach-PLATFORM/board-ss_CODENAME.c</code> (or just <code>board-CODENAME.c</code>), where PLATFORM is <code>capri</code> for BCM218xx, <code>rhea</code> for BCM21654, <code>hawaii</code> for BCM21664 and <code>java</code> for BCM23550.
 
== Adding a device package in postmarketOS ==
 
Run <code>pmbootstrap init</code>. When asked for the device, provide the vendor and codename.
 
* If you're asked to create a new device, follow the [https://wiki.postmarketos.org/wiki/Porting_to_a_new_device Porting Guide], using the <code>linux-postmarketos-brcm-kona</code> mainline kernel package.
* If this ends up selecting an existing downstream/archived device, you'll need to update the device package - see [https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/8981/diffs?commit_id=fc2eb16282fe1b9dea7fb010533568899fad1bcb the commit doing this for samsung-baffinlite] as an example.


== Adding a DTS for your device ==
== Adding a DTS for your device ==
Line 609: Line 616:
</syntaxhighlight>
</syntaxhighlight>


== WiFi and Bluetooth ==
=== WiFi and Bluetooth ===


Most Broadcom devices use Broadcom WiFi/Bluetooth chips from the BCM43xx series. (Look up BCM43 in your defconfig, or reference downstream kernel dmesg for the exact model.)
Most Broadcom devices use Broadcom WiFi/Bluetooth chips from the BCM43xx series. (Look up BCM43 in your defconfig, or reference downstream kernel dmesg for the exact model.)
Line 696: Line 703:


(Get the interrupt from <code>board_wifi_info</code>, member <code>.host_wake_gpio</code>).
(Get the interrupt from <code>board_wifi_info</code>, member <code>.host_wake_gpio</code>).
=== GPIO keys ===
Many Samsung devices use GPIO-based keys for the volume up/down and home keys. (The power button is handled by the PMIC, and the touchkeys (menu/back next to home button) are usually handled by the touchscreen).
<syntaxhighlight lang="c">
#define GPIO_KEYS_SETTINGS { \
      { KEY_VOLUMEUP,9, 1, "VOLUMEUP", EV_KEY, 0, 64}, \
{ KEY_HOME, 10, 1, "HOME", EV_KEY, 0, 64}, \
      { KEY_VOLUMEDOWN,11, 1, "VOLUMEDOWN", EV_KEY, 0, 64}, \
}
#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
static struct gpio_keys_button board_gpio_keys[] = GPIO_KEYS_SETTINGS;
/* ... */
#endif
</syntaxhighlight>
Equivalent DT fragment:
<syntaxhighlight lang="devicetree">
/ {
    /* ... */
/* Buttons */
gpio-keys {
compatible = "gpio-keys";
key-volume-up {
label = "Volume Up";
gpios = <&gpio 9 GPIO_ACTIVE_LOW>;
linux,code = <KEY_VOLUMEUP>;
};
key-home {
label = "Home";
gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
linux,code = <KEY_HOMEPAGE>;
};
key-volume-down {
label = "Volume Down";
gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
linux,code = <KEY_VOLUMEDOWN>;
};
};
   
    /* ... */
};
</syntaxhighlight>
=== Keypad ===
{{note|Keypad is only added for BCM21664/BCM23550 at the moment; it's most likely the same for BCM28155, just a matter of adding the right node like [https://github.com/bcm-kona-mainline/linux/commit/86a15664bdfe457bcd994b2ae72f722509259b53 in the equivalent bcm21664-common.dtsi commit].}}
Some devices use the built-in keypad peripheral for volume up/down keys. If you have <code>CONFIG_KEYBOARD_BCM</code> enabled in downstream defconfig, look for <code>bcm_keymap</code> in your board file:
<syntaxhighlight lang="c">
#ifdef CONFIG_KEYBOARD_BCM
static struct bcm_keymap hawaii_keymap[] = {
{BCM_KEY_ROW_0, BCM_KEY_COL_0, "unused", 0},
{BCM_KEY_ROW_0, BCM_KEY_COL_1, "Vol Down Key", KEY_VOLUMEDOWN},
{BCM_KEY_ROW_0, BCM_KEY_COL_2, "unused", 0},
{BCM_KEY_ROW_0, BCM_KEY_COL_3, "Vol Up Key", KEY_VOLUMEUP},
{BCM_KEY_ROW_0, BCM_KEY_COL_4, "unused", 0},
{BCM_KEY_ROW_0, BCM_KEY_COL_5, "unused", 0},
    /* ... */
};
static struct bcm_keypad_platform_info hawaii_keypad_data = {
.row_num = 1,
.col_num = 5,
.keymap = hawaii_keymap,
.bcm_keypad_base = (void *)__iomem HW_IO_PHYS_TO_VIRT(KEYPAD_BASE_ADDR),
};
#endif
</syntaxhighlight>
Equivalent DTS:
<syntaxhighlight lang="devicetree">
&keypad {
keypad,num-rows = <1>;
keypad,num-columns = <5>;
linux,keymap = <MATRIX_KEY(0x00, 0x01, KEY_VOLUMEDOWN)>,
      <MATRIX_KEY(0x00, 0x03, KEY_VOLUMEUP)>;
status = "okay";
};
</syntaxhighlight>
== Building the kernel ==
To apply the pmOS Broadcom Kona defconfig:
<syntaxhighlight lang="shell-session">
$ make bcmkona_pmos_defconfig
</syntaxhighlight>
To build the kernel:
<syntaxhighlight lang="shell-session">
$ make -j$(nproc)
-- or, with mainline-tools: --
$ mb
</syntaxhighlight>
If you have mainline-tools, you can flash the kernel with:
<syntaxhighlight lang="shell-session">
$ mp
$ mf
</syntaxhighlight>