|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 l2 {* P) @" I l- ]2 f2 ?
#include <linux/init.h>6 ~9 u8 H8 l$ K8 R
#include <linux/module.h>
9 A n2 z6 v8 U; O X/ |#include <linux/kernel.h>4 a' ^3 |$ o I# B
#include <linux/types.h>! N1 n) i6 S& n9 l0 l* q" Q: W) g
#include <linux/gpio.h>/ B7 q5 P' w0 g, v' V4 E8 g! {
#include <linux/leds.h>
' f0 ^! \ l( w J$ G X1 T#include <linux/platform_device.h>* ]4 T# c0 v4 C
" N! @# I; |' C3 c/ q5 y, Q5 e#include <asm/mach-types.h>
$ F6 y+ U. U6 s#include <asm/mach/arch.h>. c& B* k G1 G5 ~4 @
#include <mach/da8xx.h>
7 x! O- z& ~. |- B* X6 m/ H#include <mach/mux.h>
% s& h5 V( \$ J) @" h
8 E' Z2 [9 F* o9 t, B1 m" H! f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# O3 Q) Y/ J; S7 m+ R9 B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) ]# {% T9 ^' t4 [/ W W7 }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. l# y4 W F+ W, } w/ _/ F% t+ L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 D1 ^9 m! {1 G% L1 s; V5 E P5 W; f6 W' P
/* assign the tl som board LED-GPIOs*/. |0 t8 E! R7 N8 w# g
static const short da850_evm_tl_user_led_pins[] = {( ]1 p. l; i+ Y2 L
/* These pins are definition at <mach/mux.h> file */
q- h6 a$ g7 Z) _8 ?; e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 N5 h8 |! {2 z, _6 Q) [* N+ P
-1
/ [( V9 m# P/ Y0 }7 p1 S};
[' L* w* F! t0 ~3 b. ]9 O
4 ^4 d% M' ^ |( ^static struct gpio_led da850_evm_tl_leds[] = {
- ^0 ~ a! o) G, E: Z. w {
3 f5 K$ s$ @1 `6 l; m. l .active_low = 0,2 t9 g7 o8 k' l7 S ]6 d5 v
.gpio = DA850_USER_LED0,
) `: u/ W# y& A& r7 F) c0 U4 ?$ ? .name = "user_led0",
# B6 w& `3 s+ E" G1 } .default_trigger = "default-on",7 i- |# D0 h3 K6 y
},7 ?8 c0 ]6 |3 h# ~
{
( Q3 d( O5 X7 j; } .active_low = 0,
* y; X6 T7 b4 g6 R$ f .gpio = DA850_USER_LED1,
+ o; `) S- i p2 U4 c, c# K4 h; Y .name = "user_led1",
1 X* {' n: `3 ]' Q9 B8 r .default_trigger = "default-on",7 C4 m& I4 m; \' j9 S
},
; T$ m* ?! o) R' { {
1 Q7 f: h1 d/ d' b4 d .active_low = 0,
+ H5 M; ~$ G5 ~! _9 a .gpio = DA850_USER_LED2,
' P! h& j4 q! u x& t .name = "user_led2",
( ^+ S$ v9 c' @ .default_trigger = "default-on",& e6 |2 t; A3 I$ f8 K: ?. j
},
' U8 X! q+ ]4 B/ T/ l7 l! U) h {, ?" I% \( F, ?8 l
.active_low = 0,& j, n# c5 f, j& E. X. Y' v' p: j& f
.gpio = DA850_USER_LED3,
' }9 C2 r( L' }7 \- b. D- g _ .name = "user_led3",
, h! ^( [ C1 L, [8 M" } .default_trigger = "default-on",2 O& D \7 m V# n
},0 O2 S7 ?' M. _( S" L' n g
};
9 j5 |$ _, ?$ t/ b) K% ~ L1 I; u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ V c, N# l$ h9 L* T1 |% M
.leds = da850_evm_tl_leds,; O }* C- j5 @( u: s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 g' d, e4 j+ G
};! I8 Z+ l( F& a! P+ @/ R
3 Q9 v. B# i; a: wstatic void led_dev_release(struct device *dev)" Z4 Z/ {, @7 M, {- M% `
{& |0 o3 R1 O6 }
};
( v7 f5 L" Y# y/ v- G) U# N! b& { G: ]( e2 I
static struct platform_device da850_evm_tl_leds_device = {
/ n3 t# h F* J) p .name = "leds-gpio",) Q( L. y% z8 \; `: h
.id = 1,1 b9 M. q$ H' y
.dev = {
9 E" y/ Z- m" D8 _" f9 G3 L .platform_data = &da850_evm_tl_leds_pdata,
; n* Z# R# J6 T$ S .release = led_dev_release,/ @* w4 m) @: s- {9 D, l
} O9 P% t& d0 M
};. j0 A, u) [& D9 m( F
1 U! m5 n! O! s, |static int __init led_platform_init(void)* M, u1 D9 z8 G# `* Z! V1 Z+ l
{
. Y' H+ X. F: M- ]! H. ` int ret;9 s/ j4 b) F! Z3 }; y. m/ f
#if 0
: N3 E& u0 B/ b0 P1 Q. _$ [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 `/ B; W- _4 G' @$ E
if (ret)
# r) T+ Y- y% r2 l2 q3 Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 y0 l& G3 \ a! i "%d\n", ret);! n+ W6 F3 Q7 e6 u1 M. P
#endif: E8 C3 f3 R; K. L- v, S/ P
ret = platform_device_register(&da850_evm_tl_leds_device);
5 K5 l* O% r3 I8 E3 r5 ]* t if (ret)( c7 ]' l; p6 O& _! Y$ f6 C
pr_warning("Could not register som GPIO expander LEDS");) F: f6 n v- G4 F; r! M
else
3 E+ p& }% _0 K printk(KERN_INFO "LED register sucessful!\n");
~1 ]' V% d, F5 Q& Z) B$ I# H8 t' t, [8 r* ]9 V+ Z) k
return ret;' L! N! L( @7 k! f
}$ w3 l. g% n( }0 @* c9 X b3 K7 C; H$ ^
6 X/ N8 U+ T* D+ o! a; Ystatic void __exit led_platform_exit(void)% n0 W% r: u5 j+ m! g7 e/ V
{
# p7 R- p/ Y& a1 N/ A4 x8 x platform_device_unregister(&da850_evm_tl_leds_device);
0 }5 Y+ j3 _% M0 e L% {
! f9 Y, ^$ f: A1 z7 c) ~# m printk(KERN_INFO "LED unregister!\n");
4 e; ~2 P8 w* S/ I/ U5 w6 V}
$ h( n* h8 _% d0 E% T5 k, W2 ~2 v! ?* f J6 u0 ]( r' I
module_init(led_platform_init);2 R6 Y+ G F; I0 _: T x
module_exit(led_platform_exit);7 P% H% ^- C+ b
& L) K- O1 _. M6 V2 HMODULE_DESCRIPTION("Led platform driver");5 R9 M9 z+ f7 B" { l* h
MODULE_AUTHOR("Tronlong");
- i, s, \ V: ?3 h" Z B% yMODULE_LICENSE("GPL");
# c8 T" `- [' W0 t; M4 [; w, h9 ?* p& ~
|
|