1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: architecture/powerpc64/package/.../0070-ps3dispmgr.patch
5 # Copyright (C) 2019 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
15 # --- T2-COPYRIGHT-NOTE-END ---
17 --- a/drivers/ps3/ps3-vuart.c
18 +++ b/drivers/ps3/ps3-vuart.c
19 @@ -27,6 +27,7 @@ MODULE_DESCRIPTION("PS3 vuart");
20 * vuart - An inter-partition data link service.
21 * port 0: PS3 AV Settings.
22 * port 2: PS3 System Manager.
23 + * port 10: PS3 Dispatcher Manager.
25 * The vuart provides a bi-directional byte stream data link between logical
26 * partitions. Its primary role is as a communications link between the guest
27 @@ -34,7 +35,7 @@ MODULE_DESCRIPTION("PS3 vuart");
28 * connections other than those listed.
31 -enum {PORT_COUNT = 3,};
32 +enum {PORT_COUNT = 11,};
36 @@ -907,7 +908,7 @@ static int ps3_vuart_bus_interrupt_get(void)
38 vuart_bus_priv.use_count++;
40 - BUG_ON(vuart_bus_priv.use_count > 2);
41 + BUG_ON(vuart_bus_priv.use_count > 3);
43 if (vuart_bus_priv.use_count != 1)
45 --- a/arch/powerpc/include/asm/ps3.h
46 +++ b/arch/powerpc/include/asm/ps3.h
47 @@ -314,6 +314,7 @@ enum ps3_match_id {
48 PS3_MATCH_ID_GPU = 10,
49 PS3_MATCH_ID_LPM = 11,
50 PS3_MATCH_ID_STOR_NOR_FLASH = 12,
51 + PS3_MATCH_ID_DISP_MANAGER = 13,
54 enum ps3_match_sub_id {
55 @@ -334,6 +335,7 @@ enum ps3_match_sub_id {
56 #define PS3_MODULE_ALIAS_GPU_RAMDISK "ps3:10:2"
57 #define PS3_MODULE_ALIAS_LPM "ps3:11:0"
58 #define PS3_MODULE_ALIAS_STOR_NOR_FLASH "ps3:12:0"
59 +#define PS3_MODULE_ALIAS_DISP_MANAGER "ps3:13:0"
61 enum ps3_system_bus_device_type {
62 PS3_DEVICE_TYPE_IOC0 = 1,
63 --- a/arch/powerpc/platforms/ps3/system-bus.c
64 +++ b/arch/powerpc/platforms/ps3/system-bus.c
65 @@ -171,6 +171,7 @@ int ps3_open_hv_device(struct ps3_system_bus_device *dev)
67 case PS3_MATCH_ID_AV_SETTINGS:
68 case PS3_MATCH_ID_SYSTEM_MANAGER:
69 + case PS3_MATCH_ID_DISP_MANAGER:
70 pr_debug("%s:%d: unsupported match_id: %u\n", __func__,
71 __LINE__, dev->match_id);
72 pr_debug("%s:%d: bus_id: %llu\n", __func__, __LINE__,
73 @@ -210,6 +211,7 @@ int ps3_close_hv_device(struct ps3_system_bus_device *dev)
75 case PS3_MATCH_ID_AV_SETTINGS:
76 case PS3_MATCH_ID_SYSTEM_MANAGER:
77 + case PS3_MATCH_ID_DISP_MANAGER:
78 pr_debug("%s:%d: unsupported match_id: %u\n", __func__,
79 __LINE__, dev->match_id);
80 pr_debug("%s:%d: bus_id: %llu\n", __func__, __LINE__,
81 --- a/arch/powerpc/platforms/ps3/device-init.c
82 +++ b/arch/powerpc/platforms/ps3/device-init.c
83 @@ -412,6 +412,7 @@ static int __init ps3_register_vuart_devices(void)
86 unsigned int port_number;
87 + u64 lpar_id, laid, junk;
89 pr_debug(" -> %s:%d\n", __func__, __LINE__);
91 @@ -430,6 +431,27 @@ static int __init ps3_register_vuart_devices(void)
95 + result = lv1_get_logical_partition_id(&lpar_id);
99 + result = lv1_read_repository_node(1, 0x0000000073730000ul /* ss */,
100 + 0x6c61696400000000ul /* laid */,
106 + if (laid == 0x1070000002000001ul) {
108 + result = ps3_setup_vuart_device(PS3_MATCH_ID_DISP_MANAGER,
116 pr_debug(" <- %s:%d\n", __func__, __LINE__);
119 --- a/drivers/ps3/Makefile
120 +++ b/drivers/ps3/Makefile
121 @@ -6,3 +6,4 @@ obj-$(CONFIG_PPC_PS3) += sys-manager-core.o
122 obj-$(CONFIG_PS3_SYS_MANAGER) += ps3-sys-manager.o
123 obj-$(CONFIG_PS3_STORAGE) += ps3stor_lib.o
124 obj-$(CONFIG_PS3_LPM) += ps3-lpm.o
125 +obj-$(CONFIG_PS3_DISP_MANAGER) += ps3-disp-manager.o
126 --- a/arch/powerpc/platforms/ps3/Kconfig
127 +++ b/arch/powerpc/platforms/ps3/Kconfig
128 @@ -97,6 +97,17 @@ config PS3_REPOSITORY_WRITE
129 If in doubt, say N here and reduce the size of the kernel by a
132 +config PS3_DISP_MANAGER
134 + tristate "PS3 Dispatcher Manager driver" if PS3_ADVANCED
138 + Include support for the PS3 Dispatcher Manager.
140 + This support is required to access the PS3 SS services.
141 + In general, all users will say Y or M.
147 +++ b/drivers/ps3/ps3-disp-manager.c
150 + * PS3 Dispatcher Manager.
152 + * Copyright (C) 2011 graf_chokolo <grafchokolo@gmail.com>.
153 + * Copyright (C) 2011, 2012 glevand <geoffrey.levand@mail.ru>.
155 + * This program is free software; you can redistribute it and/or modify
156 + * it under the terms of the GNU General Public License as published by
157 + * the Free Software Foundation; version 2 of the License.
159 + * This program is distributed in the hope that it will be useful,
160 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
161 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
162 + * GNU General Public License for more details.
164 + * You should have received a copy of the GNU General Public License
165 + * along with this program; if not, write to the Free Software
166 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
169 +#include <linux/kernel.h>
170 +#include <linux/module.h>
171 +#include <linux/slab.h>
172 +#include <linux/uaccess.h>
173 +#include <linux/fs.h>
174 +#include <linux/miscdevice.h>
176 +#include <asm/firmware.h>
177 +#include <asm/lv1call.h>
178 +#include <asm/ps3.h>
182 +#define DEVICE_NAME "ps3dispmngr"
184 +static struct ps3dm {
185 + struct ps3_system_bus_device *dev;
186 + struct miscdevice misc;
189 +static ssize_t ps3_disp_manager_read(struct file *file, char __user *usrbuf,
190 + size_t count, loff_t *pos)
195 + buf = kmalloc(count, GFP_KERNEL);
199 + result = ps3_vuart_read(ps3dm->dev, buf, count);
203 + if (copy_to_user(usrbuf, buf, count)) {
217 +static ssize_t ps3_disp_manager_write(struct file *file, const char __user *usrbuf,
218 + size_t count, loff_t *pos)
223 + buf = kmalloc(count, GFP_KERNEL);
227 + if (copy_from_user(buf, usrbuf, count)) {
232 + result = ps3_vuart_write(ps3dm->dev, buf, count);
245 +static const struct file_operations ps3_disp_manager_fops = {
246 + .owner = THIS_MODULE,
247 + .read = ps3_disp_manager_read,
248 + .write = ps3_disp_manager_write,
251 +static int ps3_disp_manager_probe(struct ps3_system_bus_device *dev)
255 + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__);
258 + dev_err(&dev->core, "Only one Dispatcher Manager is supported\n");
262 + ps3dm = kzalloc(sizeof(*ps3dm), GFP_KERNEL);
268 + ps3dm->misc.parent = &dev->core;
269 + ps3dm->misc.minor = MISC_DYNAMIC_MINOR,
270 + ps3dm->misc.name = DEVICE_NAME,
271 + ps3dm->misc.fops = &ps3_disp_manager_fops,
273 + result = misc_register(&ps3dm->misc);
275 + dev_err(&dev->core, "%s:%u: misc_register failed %d\n",
276 + __func__, __LINE__, result);
280 + dev_info(&dev->core, "%s:%u: registered misc device %d\n",
281 + __func__, __LINE__, ps3dm->misc.minor);
283 + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__);
295 +static int ps3_disp_manager_remove(struct ps3_system_bus_device *dev)
297 + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__);
300 + misc_deregister(&ps3dm->misc);
308 +static void ps3_disp_manager_shutdown(struct ps3_system_bus_device *dev)
310 + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__);
313 +static struct ps3_vuart_port_driver ps3_disp_manager = {
314 + .core.match_id = PS3_MATCH_ID_DISP_MANAGER,
315 + .core.core.name = "ps3_disp_manager",
316 + .probe = ps3_disp_manager_probe,
317 + .remove = ps3_disp_manager_remove,
318 + .shutdown = ps3_disp_manager_shutdown,
321 +static int __init ps3_disp_manager_init(void)
323 + if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
326 + return ps3_vuart_port_driver_register(&ps3_disp_manager);
329 +static void __exit ps3_disp_manager_exit(void)
331 + pr_debug(" -> %s:%d\n", __func__, __LINE__);
333 + ps3_vuart_port_driver_unregister(&ps3_disp_manager);
335 + pr_debug(" <- %s:%d\n", __func__, __LINE__);
338 +module_init(ps3_disp_manager_init);
339 +module_exit(ps3_disp_manager_exit);
341 +MODULE_AUTHOR("glevand");
342 +MODULE_LICENSE("GPL v2");
343 +MODULE_DESCRIPTION("PS3 Dispatcher Manager");
344 +MODULE_ALIAS(PS3_MODULE_ALIAS_DISP_MANAGER);