Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for booting on T8012 (T2) SoC #425

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

asdfugil
Copy link
Contributor

@asdfugil asdfugil commented Dec 1, 2024

This PR contains the changes required to boot the kernel on T2 per this LKML submission:

https://lore.kernel.org/asahi/20241201161942.36027-1-towinchenmi@gmail.com/T/#t

Overall T2 is similar to A10, and this takes care of the remaining:

  • The ultra-narrow touch bar screen, or no screen at all
  • Some memory channels being unused on some devices
  • Some ADT oddities
  • Takes the memory intended for SSD cache and allow the kernel to use it (If a driver for booting x86 ever end up getting made that memory has to be described anyways)

P.S. T2 Boots on the P-core in Apple Fusion Architecture

@asdfugil asdfugil marked this pull request as draft December 3, 2024 05:18
@asdfugil asdfugil marked this pull request as ready for review December 3, 2024 05:19
@asdfugil asdfugil closed this Jan 29, 2025
@asdfugil asdfugil deleted the for-upstream branch January 29, 2025 20:07
@asdfugil asdfugil restored the for-upstream branch January 29, 2025 20:07
@asdfugil asdfugil reopened this Jan 29, 2025
Address some peculiarities specific to T2:

- Reserved memory at top is very large, either 512 MB or 1536 MB, and only
lowest 512 MB is for OS use.

- Some ranges in /arm-io/ranges is not aligned to the page size. We align
them ourselves instead.

- On models with a screen, the framebuffer is extremely narrow at 60 pixels
in width, so add a smaller logo.

Signed-off-by: Nick Chan <towinchenmi@gmail.com>
- Some devices does not have a display internal or external, do not try to
prepare framebuffer on it.

- Describe the x86 SSD cache on T2, since any potential driver will also
need that memory range to be described. For now though, it can be used
as normal memory.

- Only half of the memory channels are used on T2 with 1 GB of memory,
and this fact must be learned at runtime because the amount of memory
depends on the storage configuration of the host Mac.

Signed-off-by: Nick Chan <towinchenmi@gmail.com>
u64 cache_min = ALIGN_UP(dram_max, BIT(29));
u64 cache_max = dram_base + dram_size;

/* Set x86 SSD Cache as OS memory, any potential driver would need the memory described
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work with an actual driver, it just abuses this region as main memory. If a driver were to use this, it would have to be described as reserved-memory (which automatically adds it to the list if mapped).

If you intend to ever actually support ANS here, then this probably needs to be kept reserved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I will not describe this memory region for now, given that it might need new compatibles and stuff and that that part of the hardware is not well understood. In this case, this memory region only needs to be concerned while correcting mem_size_actual.

/* Set x86 SSD Cache as OS memory, any potential driver would need the memory described
* anyways */

memreg[num_regions].start = cpu_to_fdt64(cache_min);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing bounds check.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants