From patchwork Wed Oct 28 08:05:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar Kushwaha X-Patchwork-Id: 537229 X-Patchwork-Delegate: yorksun@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 7581E1409F8 for ; Wed, 28 Oct 2015 19:07:39 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5ABE44B712; Wed, 28 Oct 2015 09:07:02 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G7dK969ahl4O; Wed, 28 Oct 2015 09:07:02 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5C6164B716; Wed, 28 Oct 2015 09:06:49 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2F5B34B67D for ; Wed, 28 Oct 2015 09:06:16 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wwmklqzH-Jca for ; Wed, 28 Oct 2015 09:06:16 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0136.outbound.protection.outlook.com [157.56.111.136]) by theia.denx.de (Postfix) with ESMTPS id 4EF5E4B67F for ; Wed, 28 Oct 2015 09:06:11 +0100 (CET) Received: from DM2PR03CA0032.namprd03.prod.outlook.com (10.141.96.31) by BN1PR0301MB0658.namprd03.prod.outlook.com (10.160.171.19) with Microsoft SMTP Server (TLS) id 15.1.306.13; Wed, 28 Oct 2015 08:06:06 +0000 Received: from BN1AFFO11FD008.protection.gbl (2a01:111:f400:7c10::137) by DM2PR03CA0032.outlook.office365.com (2a01:111:e400:2428::31) with Microsoft SMTP Server (TLS) id 15.1.312.18 via Frontend Transport; Wed, 28 Oct 2015 08:06:05 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD008.mail.protection.outlook.com (10.58.52.68) with Microsoft SMTP Server (TLS) id 15.1.306.13 via Frontend Transport; Wed, 28 Oct 2015 08:06:05 +0000 Received: from b32579-VirtualBox.ap.freescale.net (B32579-02.ap.freescale.net [10.232.40.252]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t9S85AGm023380; Wed, 28 Oct 2015 01:06:03 -0700 From: Prabhakar Kushwaha To: Date: Wed, 28 Oct 2015 13:35:07 +0530 Message-ID: <1446019509-24687-9-git-send-email-prabhakar@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446019509-24687-1-git-send-email-prabhakar@freescale.com> References: <1446019509-24687-1-git-send-email-prabhakar@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD008; 1:sCBuQtRXxWx7LRkH7SqNp1zqjeWgXzlVHpe1jrqqW1Ejy5MzoXKTn1Z3yrPVwFO8hBoQCd6E1yYdOaepu2zaIHtiI/hnIzBOkQs+0SRlzN+nFBCvV8q8nKtKtTYeX8TaziolrOauvQd4WjRxlww2cQwHFt2+rLaDdD6BiVnPbIcLCPT4jGnWNwCUfWZH833RoWTQYLrgG7DDPxn1aJqJwfEY49ETmmpbEavmZBG1r+ULjHlvoSNRmrNCJ1vLxkSc3y0FoHf3bqZVw5J2Zh+Rtx5b4syKHB8eyJ4jjiifSv856WLu47Vx83EbbQqTve2MHOIaZl7ImSMsru18OS9Wr0P4IcjQT3Vabj9nbi/Cv2Mu8VDtkJHdynXlV9DmH2QLmx98lWY/0c6HhowH4KvBuw== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(5001960100002)(5003940100001)(229853001)(106466001)(77096005)(19580405001)(50226001)(33646002)(107886002)(19580395003)(2351001)(110136002)(86362001)(189998001)(85426001)(450100001)(81156007)(87936001)(105606002)(11100500001)(97736004)(6806005)(2950100001)(5008740100001)(47776003)(5007970100001)(36756003)(76176999)(104016004)(48376002)(4001430100002)(92566002)(50466002)(50986999); DIR:OUT; SFP:1102; SCL:1; SRVR:BN1PR0301MB0658; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0658; 2:NyJCzPlyK010gXGkxwVwh3EkEAa+5tO/meY0cwe3F7q/xJ17XPLfqNzdqDX4/81q9eexb+5i2yHgsBlO8dCTmYanmHQ9BdSKbGzERYftgamz6l2wQgy34wZZ5hjz3oYD376VgGDZ6SrwuOahW6oDMz5J50hz94CtLHbdvj6GHWI=; 3:/a+FGtYi817gdXSWISd9t9kZTyWdJZtde62tZKsG+2d80lh1NVIavSXsDOdbqA5HkcXJg0M9IcAhpjazd2GIeopES9DFNTzcpcRzCYutpD5J/39Y/9voy2+SLCJrWSqSmnQ1ZWYkQLStwRPL+vwoTSknu3eVZkmDxlq482Lxex0sheMYd3DDYk+Md83fIMNO+S5pqX+6tQi/niYkuRNakOnGxNBLI/sNoIQ+tfV8DTU=; 25:KYsc6s0jYCsOoHBiAzWlTi0tR5Gms8p/P/+CiQhmWTR3OOjUWSvV/0JQ/7GkN9pQ7Nh04TFCHaPXkJN7gUowVh+vSzpuOZtnYXVzSdxFUqa2e7zZCZuqG/dE5ViLEaRS0I/3YCxIJMY9m2qG/utMTOTCq34DWAsc4JFjVv89yekOrBh+JdrBNw2NpsvOpJmH9+ddBcooMLBacuwVUioMXMdtwj07gZQY/rmlpYc2WNd+8GDebpZ4yBWB85+pom3B5nChrATMc1VvTrcJ2GG1Xg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR0301MB0658; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0658; 20:E/SxwkFjr4bIRrjnsPHQmNEEhJiq60UpCgygMZqXe9y6rk12wTx/J95Sq9LjPoZ+/p8m2wXV/qT2q8bjDF7wEx23SwjxRetam2jqCoIkPCt5y6Q3HKNrhtgjwvQGITk3Fax5Pf97jP1D5+xE3SdzEt6jbF+DHot7fVzp88v4ny85+JUf6uB9Tl6dCU6frXj9UH1tigMYHutquSwHAs/q6736NUGMoZUg7bRK1BVbvXdbrWE1d/bfk7xuRSsC/c57prF9ua3eMtWoIQL6TIvxeHrqE2T8rQxvyHjFwn/hTT6ysaA6Ol7d7A003uE0bxoF+/YC7aDPsI0lq39nl9vq+4Vp2tC82yqBNbF/ZB0cJAY=; 4:l1rhB4z7Dv4lwYTUut5UEUcxlR8tKmaZ0xcmVFHcH7+nuXJWNTP5Uq7ZL0s97GSAAnOp2ro7A7za6vBpDNmMjFdCj2mKqpDqc+NhaLMYKDtcYzFZsTlkSJcLJpyR20eejd1NqueTqVPwhh+V68lpv6iLiMSNihKJ6fCc9u0FjI0gBkUdy4TnOJRyTyZqLo1iLshA5H/lZUNwTDW9h20z7UQux5TjmuJhpZqKO0/vcL8PQKP/oC6l11c+5xT3JQl49+EOnA1802nqHEziK/vUJLG7wnVb5PFxvOxa5n5Yvg05mCwcn1BjpQ7cdqQa1xw4BdNDAxZjjYT+EmRwARD85ZtFYnR/n7lIxHKG1IzzsW1tsbawgPWmn+MR3UktDztGxv2GaII4WQ3tLiWEIAXYJA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046)(102215026); SRVR:BN1PR0301MB0658; BCL:0; PCL:0; RULEID:; SRVR:BN1PR0301MB0658; X-Forefront-PRVS: 0743E8D0A6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0301MB0658; 23:Td9munsqGyr2EinPQGTbmnMoKDALm7+qsYKAOVn?= =?us-ascii?Q?I1M3nfn9agH770exnxaTMn/89CUJ9yiACvh6cb/dvEMISA8zF3llhYKIpw8Z?= =?us-ascii?Q?O9kzPw+h7fotEPfgMuIhO74DO37727vPM3ksBzWOm1NfJ8rnTHASmVXZxolh?= =?us-ascii?Q?8qmVzxqIILMNi0fWfZcy+lOKK0V72hj7d3I45YzrwlWUL7+tqTsoSXb3A65c?= =?us-ascii?Q?ngCqXOLp/bwIll2qxCcA9wtQyMmAcw/xf/pEEqJQvJBs7Z5cD72CQTtfLVUn?= =?us-ascii?Q?bgmvn4eF+JcuRTDolVUMkxlqHMQw/nVsKY0esjBrdjAnOJ8f7HkjZbrKd6h3?= =?us-ascii?Q?EPVDTQJ+LhYp+ANgOZL278u+KkebknRE3y9FT32hlQq1b1aYn/TsTdk6K2oq?= =?us-ascii?Q?gA9nY46G5E+6JcFYNF3NEOnzNwnlrqKp04WkU8OMxqB7QAN/oQOdV8eKbaP+?= =?us-ascii?Q?pxYa4m1UjBZLodsIuzSaUwMbuuNeN583k6HFHwqrfZmVdVoDirRU16XkLADG?= =?us-ascii?Q?vQFA7GtvLh1Bg2Bw46JjOyGRqHGyeoMBOEWpPb7RpEefiwaGd/VwlkKrV00z?= =?us-ascii?Q?HPdZ+t6C+qwsoYyOpx/AZmjqpbitJUFll6iJrqsekuakj71R+wX6pbwY2BOZ?= =?us-ascii?Q?sIH2fh8w1+xnDBH04drUqbIzzdxWd6VmnHmA0IpTr2Q1CljYcjCL4bWTawaw?= =?us-ascii?Q?cTwIL32qvQRgfCOLYOum3NecotmGE4+vaMw7/glP4y0FeLe7t35vf+l0GD7t?= =?us-ascii?Q?/HqOmm5DROfKxfIWvhFhmNU2unToxplUEFEjT07i7i7R5Mvxax0AAiBK1MB5?= =?us-ascii?Q?obPFHuPexTNF0FPRU2muKqtLAQbB6f4NZY+ZYpBEWMbIlLjOicufs6uDY6m0?= =?us-ascii?Q?loQJjJOL2GHw1wtglzNzH8wgJeB03PokdWbzLR3+OPHS5ApwKuSR1fRelftA?= =?us-ascii?Q?7TifAhU0Z0xYnrXWn8dmu+dKsgwG0seNh4yOJmVyjzuJq+BvHkCKRb93oyvh?= =?us-ascii?Q?qjNmMAfcdOtvT6d8bU3QHm2BnNrnonv5uSsyjTDRyuoigCZRmwSOYEDCWA50?= =?us-ascii?Q?j20gqOOuaJFqag9RwlQTU+RQrkFmnXnt7qz0vJvz807Ys5HeoPL6ngmPjIoe?= =?us-ascii?Q?0khBI6Y/dlz4=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0658; 5:mMkLfTPUOOTGfKmYt6ehVYKKHpEfYNGnzKSYxtc5JpsOtdGXLUmK8dDfq3JiyocjlKmtqabXkC7nVLX+lkN5X2Exrf3TzticRfbpvWz+w1sfZPFHkpAq8MXLkgbPUZQNALrv4BxCdz+YSVWdzcPRwQ==; 24:F85jl7w78P0Qgz3DXQRKC/w/vUAJBPac6UYsAJtbf2zi7RG18VRicaxtrjAEiJUz/dHy39f6E2DB/o599nTaOMJN5HIhLIfYtGumqzqio1c=; 20:H2NusOudmT1QxQJh4bK2JSSWwk4KaP+t0ZafdHTZB53eAQ9QusZVtgnuaHqkaE8JaVv1+ktgSjrKeDtEShnYDg== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2015 08:06:05.5305 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0301MB0658 Cc: yorksun@freescale.com Subject: [U-Boot] [PATCH 08/10] driver: net: fsl-mc: Create DPAA2 object at run-time X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Freescale's DPAA2 ethernet driver depends upon the static DPL for the DPRC, DPNI, DPBP, DPIO objects. Instead of static objects, Create DPNI, DPBP, DPIO objects at run-time. Signed-off-by: Prabhakar Kushwaha --- board/freescale/ls2085aqds/ls2085aqds.c | 1 - board/freescale/ls2085ardb/ls2085ardb.c | 1 - drivers/net/fsl-mc/mc.c | 332 +++++++++++++++++++++++++++++--- drivers/net/ldpaa_eth/ldpaa_eth.c | 4 +- include/fsl-mc/fsl_mc.h | 1 - include/fsl-mc/fsl_mc_private.h | 23 ++- 6 files changed, 327 insertions(+), 35 deletions(-) diff --git a/board/freescale/ls2085aqds/ls2085aqds.c b/board/freescale/ls2085aqds/ls2085aqds.c index b02d6e8..922242c 100644 --- a/board/freescale/ls2085aqds/ls2085aqds.c +++ b/board/freescale/ls2085aqds/ls2085aqds.c @@ -309,7 +309,6 @@ int ft_board_setup(void *blob, bd_t *bd) #ifdef CONFIG_FSL_MC_ENET fdt_fixup_board_enet(blob); - fsl_mc_ldpaa_exit(bd); #endif return 0; diff --git a/board/freescale/ls2085ardb/ls2085ardb.c b/board/freescale/ls2085ardb/ls2085ardb.c index 18953b8..3533f20 100644 --- a/board/freescale/ls2085ardb/ls2085ardb.c +++ b/board/freescale/ls2085ardb/ls2085ardb.c @@ -275,7 +275,6 @@ int ft_board_setup(void *blob, bd_t *bd) #ifdef CONFIG_FSL_MC_ENET fdt_fixup_board_enet(blob); - fsl_mc_ldpaa_exit(bd); #endif return 0; diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c index 781e221..0a1dae1 100644 --- a/drivers/net/fsl-mc/mc.c +++ b/drivers/net/fsl-mc/mc.c @@ -32,10 +32,11 @@ static int mc_dpl_applied = -1; static int mc_aiop_applied = -1; #endif struct fsl_mc_io *dflt_mc_io = NULL; +uint16_t root_dprc_handle; uint16_t dflt_dprc_handle = 0; struct fsl_dpbp_obj *dflt_dpbp = NULL; struct fsl_dpio_obj *dflt_dpio = NULL; -uint16_t dflt_dpio_handle = 0; +struct fsl_dpni_obj *dflt_dpni = NULL; #ifdef DEBUG void dump_ram_words(const char *title, void *addr) @@ -648,36 +649,51 @@ unsigned long mc_get_dram_block_size(void) return dram_block_size; } -int dpio_init(struct dprc_obj_desc obj_desc) +int fsl_mc_ldpaa_init(bd_t *bis) +{ + return 0; +} + +static int dpio_init(void) { struct qbman_swp_desc p_des; struct dpio_attr attr; + struct dpio_cfg dpio_cfg; int err = 0; dflt_dpio = (struct fsl_dpio_obj *)malloc(sizeof(struct fsl_dpio_obj)); if (!dflt_dpio) { - printf(" No memory: malloc() failed\n"); - return -ENOMEM; + printf("No memory: malloc() failed\n"); + err = -ENOMEM; + goto err_malloc; } - dflt_dpio->dpio_id = obj_desc.id; + dpio_cfg.channel_mode = DPIO_LOCAL_CHANNEL; + dpio_cfg.num_priorities = 8; - err = dpio_open(dflt_mc_io, MC_CMD_NO_FLAGS, obj_desc.id, - &dflt_dpio_handle); - if (err) { - printf("dpio_open() failed\n"); - goto err_open; + err = dpio_create(dflt_mc_io, MC_CMD_NO_FLAGS, &dpio_cfg, + &dflt_dpio->dpio_handle); + if (err < 0) { + printf("dpio_create() failed: %d\n", err); + err = -ENODEV; + goto err_create; } + memset(&attr, 0, sizeof(struct dpio_attr)); err = dpio_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS, - dflt_dpio_handle, &attr); - if (err) { - printf("dpio_get_attributes() failed %d\n", err); + dflt_dpio->dpio_handle, &attr); + if (err < 0) { + printf("dpio_get_attributes() failed: %d\n", err); goto err_get_attr; } - err = dpio_enable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio_handle); - if (err) { + dflt_dpio->dpio_id = attr.id; +#ifdef DEBUG + printf("Init: DPIO id=0x%d\n", dflt_dpio->dpio_id); +#endif + + err = dpio_enable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); + if (err < 0) { printf("dpio_enable() failed %d\n", err); goto err_get_enable; } @@ -700,36 +716,291 @@ int dpio_init(struct dprc_obj_desc obj_desc) return 0; err_get_swp_init: + dpio_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); err_get_enable: - dpio_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio_handle); -err_get_attr: - dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio_handle); -err_open: free(dflt_dpio); +err_get_attr: + dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); + dpio_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); +err_create: +err_malloc: return err; } -int dpbp_init(struct dprc_obj_desc obj_desc) +static int dpio_exit(void) { + int err; + + err = dpio_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); + if (err < 0) { + printf("dpio_disable() failed: %d\n", err); + goto err; + } + + err = dpio_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); + if (err < 0) { + printf("dpio_destroy() failed: %d\n", err); + goto err; + } + +#ifdef DEBUG + printf("Exit: DPIO id=0x%d\n", dflt_dpio->dpio_id); +#endif + + if (dflt_dpio) + free(dflt_dpio); + + return 0; +err: + return err; +} + +static int dpbp_init(void) +{ + int err; + struct dpbp_attr dpbp_attr; + struct dpbp_cfg dpbp_cfg; + dflt_dpbp = (struct fsl_dpbp_obj *)malloc(sizeof(struct fsl_dpbp_obj)); if (!dflt_dpbp) { - printf(" No memory: malloc() failed\n"); - return -ENOMEM; + printf("No memory: malloc() failed\n"); + err = -ENOMEM; + goto err_malloc; + } + + dpbp_cfg.options = 512; + + err = dpbp_create(dflt_mc_io, MC_CMD_NO_FLAGS, &dpbp_cfg, + &dflt_dpbp->dpbp_handle); + + if (err < 0) { + err = -ENODEV; + printf("dpbp_create() failed: %d\n", err); + goto err_create; + } + + memset(&dpbp_attr, 0, sizeof(struct dpbp_attr)); + err = dpbp_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS, + dflt_dpbp->dpbp_handle, + &dpbp_attr); + if (err < 0) { + printf("dpbp_get_attributes() failed: %d\n", err); + goto err_get_attr; + } + + dflt_dpbp->dpbp_attr.id = dpbp_attr.id; +#ifdef DEBUG + printf("Init: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id); +#endif + + err = dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); + if (err < 0) { + printf("dpbp_close() failed: %d\n", err); + goto err_close; } - dflt_dpbp->dpbp_attr.id = obj_desc.id; return 0; + +err_close: + free(dflt_dpbp); +err_get_attr: + dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); + dpbp_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); +err_create: +err_malloc: + return err; } -int fsl_mc_ldpaa_init(bd_t *bis) +static int dpbp_exit(void) +{ + int err; + + err = dpbp_open(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_attr.id, + &dflt_dpbp->dpbp_handle); + if (err < 0) { + printf("dpbp_open() failed: %d\n", err); + goto err; + } + + err = dpbp_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, + dflt_dpbp->dpbp_handle); + if (err < 0) { + printf("dpbp_destroy() failed: %d\n", err); + goto err; + } + +#ifdef DEBUG + printf("Exit: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id); +#endif + + if (dflt_dpbp) + free(dflt_dpbp); + return 0; + +err: + return err; +} + +static int dpni_init(void) +{ + int err; + struct dpni_attr dpni_attr; + struct dpni_cfg dpni_cfg; + + dflt_dpni = (struct fsl_dpni_obj *)malloc(sizeof(struct fsl_dpni_obj)); + if (!dflt_dpni) { + printf("No memory: malloc() failed\n"); + err = -ENOMEM; + goto err_malloc; + } + + memset(&dpni_cfg, 0, sizeof(dpni_cfg)); + dpni_cfg.adv.options = DPNI_OPT_UNICAST_FILTER | + DPNI_OPT_MULTICAST_FILTER; + + err = dpni_create(dflt_mc_io, MC_CMD_NO_FLAGS, &dpni_cfg, + &dflt_dpni->dpni_handle); + + if (err < 0) { + err = -ENODEV; + printf("dpni_create() failed: %d\n", err); + goto err_create; + } + + memset(&dpni_attr, 0, sizeof(struct dpni_attr)); + err = dpni_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS, + dflt_dpni->dpni_handle, + &dpni_attr); + if (err < 0) { + printf("dpni_get_attributes() failed: %d\n", err); + goto err_get_attr; + } + + dflt_dpni->dpni_id = dpni_attr.id; +#ifdef DEBUG + printf("Init: DPNI id=0x%d\n", dflt_dpni->dpni_id); +#endif + + err = dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle); + if (err < 0) { + printf("dpni_close() failed: %d\n", err); + goto err_close; + } + + return 0; + +err_close: + free(dflt_dpni); +err_get_attr: + dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle); + dpni_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle); +err_create: +err_malloc: + return err; +} + +static int dpni_exit(void) { + int err; + + err = dpni_open(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_id, + &dflt_dpni->dpni_handle); + if (err < 0) { + printf("dpni_open() failed: %d\n", err); + goto err; + } + + err = dpni_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, + dflt_dpni->dpni_handle); + if (err < 0) { + printf("dpni_destroy() failed: %d\n", err); + goto err; + } +#ifdef DEBUG + printf("Exit: DPNI id=0x%d\n", dflt_dpni->dpni_id); +#endif + + if (dflt_dpni) + free(dflt_dpni); return 0; + +err: + return err; } -void fsl_mc_ldpaa_exit(bd_t *bis) +static int mc_init_object(void) { - return; + int err = 0; + + err = dprc_open(dflt_mc_io, MC_CMD_NO_FLAGS, 1, &root_dprc_handle); + if (err < 0) { + printf("dprc_open() failed: %d\n", err); + goto err; + } + + if (!root_dprc_handle) { + printf("dprc_open(): Handle is not valid\n"); + goto err; + } + + err = dpbp_init(); + if (err < 0) { + printf("dpbp_init() failed: %d\n", err); + goto err; + } + + err = dpio_init(); + if (err < 0) { + printf("dpio_init() failed: %d\n", err); + goto err; + } + + err = dpni_init(); + if (err < 0) { + printf("dpni_init() failed: %d\n", err); + goto err; + } + + return 0; +err: + return err; +} + +int fsl_mc_ldpaa_exit(void) +{ + int err = 0; + + err = dpbp_exit(); + if (err < 0) { + printf("dpni_exit() failed: %d\n", err); + goto err; + } + + err = dpio_exit(); + if (err < 0) { + printf("dpio_exit() failed: %d\n", err); + goto err; + } + + err = dpni_exit(); + if (err < 0) { + printf("dpni_exit() failed: %d\n", err); + goto err; + } + + if (dflt_mc_io) + free(dflt_mc_io); + + err = dprc_close(dflt_mc_io, MC_CMD_NO_FLAGS, root_dprc_handle); + if (err < 0) { + printf("dprc_close() failed: %d\n", err); + goto err; + } + + return 0; +err: + return err; } static int do_fsl_mc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) @@ -757,7 +1028,9 @@ static int do_fsl_mc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) mc_fw_addr = simple_strtoull(argv[3], NULL, 16); mc_dpc_addr = simple_strtoull(argv[4], NULL, 16); - err = mc_init(mc_fw_addr, mc_dpc_addr); + + if (!mc_init(mc_fw_addr, mc_dpc_addr)) + err = mc_init_object(); break; #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET @@ -800,12 +1073,15 @@ static int do_fsl_mc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) mc_dpl_addr = simple_strtoull(argv[3], NULL, 16); + if (get_mc_boot_status() != 0) { printf("fsl-mc: Deploying data path layout .."); printf("ERROR (MC is not booted)\n"); return -ENODEV; } - err = mc_apply_dpl(mc_dpl_addr); + + if (!fsl_mc_ldpaa_exit()) + err = mc_apply_dpl(mc_dpl_addr); break; } default: diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c index 99acb7a..cfeb45f 100644 --- a/drivers/net/ldpaa_eth/ldpaa_eth.c +++ b/drivers/net/ldpaa_eth/ldpaa_eth.c @@ -601,7 +601,7 @@ static int ldpaa_eth_netdev_init(struct eth_device *net_dev) return 0; } -int ldpaa_eth_init(struct dprc_obj_desc obj_desc) +int ldpaa_eth_init(int id) { struct eth_device *net_dev = NULL; struct ldpaa_eth_priv *priv = NULL; @@ -626,7 +626,7 @@ int ldpaa_eth_init(struct dprc_obj_desc obj_desc) net_dev->priv = (void *)priv; priv->net_dev = (struct eth_device *)net_dev; - priv->dpni_id = obj_desc.id; + priv->dpni_id = id; err = ldpaa_eth_netdev_init(net_dev); if (err) diff --git a/include/fsl-mc/fsl_mc.h b/include/fsl-mc/fsl_mc.h index c8f168a..20d4d6d 100644 --- a/include/fsl-mc/fsl_mc.h +++ b/include/fsl-mc/fsl_mc.h @@ -57,5 +57,4 @@ int get_aiop_apply_status(void); u64 mc_get_dram_addr(void); unsigned long mc_get_dram_block_size(void); int fsl_mc_ldpaa_init(bd_t *bis); -void fsl_mc_ldpaa_exit(bd_t *bis); #endif diff --git a/include/fsl-mc/fsl_mc_private.h b/include/fsl-mc/fsl_mc_private.h index 9421362..191783a 100644 --- a/include/fsl-mc/fsl_mc_private.h +++ b/include/fsl-mc/fsl_mc_private.h @@ -18,13 +18,14 @@ #include #include #include +#include extern struct fsl_mc_io *dflt_mc_io; /** * struct dpbp_node - DPBP strucuture * @uint16_t handle: DPBP object handle - * @int dpbp_id: DPBP id + * @struct dpbp_attr: DPBP attribute */ struct fsl_dpbp_obj { uint16_t dpbp_handle; @@ -40,11 +41,29 @@ extern struct fsl_dpbp_obj *dflt_dpbp; */ struct fsl_dpio_obj { int dpio_id; + uint16_t dpio_handle; struct qbman_swp *sw_portal; /** SW portal object */ }; extern struct fsl_dpio_obj *dflt_dpio; +/** + * struct dpni_node - DPNI strucuture + * @int dpni_id: DPNI id + * @uint16_t handle: DPNI object handle + * @struct dpni_attr: DPNI attributes + * @struct dpni_buffer_layout: DPNI buffer layout + */ +struct fsl_dpni_obj { + int dpni_id; + uint16_t dpni_handle; + struct dpni_attr dpni_attrs; + struct dpni_buffer_layout buf_layout; +}; + +extern struct fsl_dpni_obj *dflt_dpni; + int mc_init(u64 mc_fw_addr, u64 mc_dpc_addr); -int ldpaa_eth_init(struct dprc_obj_desc obj_desc); +int ldpaa_eth_init(int dpmac_id); +int mc_apply_dpl(u64 mc_dpl_addr); #endif /* _FSL_MC_PRIVATE_H_ */