|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 V B5 o/ h4 K. n4 I: H1 X#include <linux/init.h>
" I ]4 D( B5 X#include <linux/module.h>6 Z0 q+ q" p) } q
#include <linux/kernel.h>/ Z. A8 |* ^% w" X
#include <linux/types.h>/ e% w& G# j* `1 i
#include <linux/gpio.h>; Y6 J; u R& N& N& n; k
#include <linux/leds.h>
/ M9 I8 }* j+ r8 U8 m#include <linux/platform_device.h>2 ^4 D4 b/ B1 I& w* A7 c6 a
p! S1 T* _( F1 W, v4 }9 U' P
#include <asm/mach-types.h>; ] h& D; A2 u, [, p- K; h9 B
#include <asm/mach/arch.h>
( ]! j* ?9 `2 W. @#include <mach/da8xx.h>
1 o0 ?' X; O8 @+ f& w# a! Q. Q#include <mach/mux.h>
, f; v% S3 Q4 m; D: [, P! ^) K$ m5 W! J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 m u ?( i- l: P$ S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ G; L9 L3 M4 Y) i8 W8 d6 w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 F/ j' T* ?: g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- `+ w. m) v! [" z! b
1 P4 Q# e6 f1 ?/* assign the tl som board LED-GPIOs*/' b* h3 x1 h$ E* x; P6 Z# z
static const short da850_evm_tl_user_led_pins[] = {- o4 Z3 }7 @4 Y& V9 x
/* These pins are definition at <mach/mux.h> file */5 [3 f2 Z1 R# L, ^, `; M9 g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! u( `2 n$ J( U! [
-1
0 k ~2 y/ ?5 ?1 H) D! v. N};" B3 H# s) p; P
6 C6 D7 M( g5 {5 P8 V, p0 s- `
static struct gpio_led da850_evm_tl_leds[] = {
5 F6 \) P; T9 N/ w7 [& Q$ Y& | {/ X2 r! ]% |# v2 b
.active_low = 0,' I- z: W) }) m9 u, [
.gpio = DA850_USER_LED0,, U$ Y" m0 N; Y7 E9 u
.name = "user_led0",
& Q1 G' h1 c6 ?# R .default_trigger = "default-on",6 ?4 C y) m! A6 Z( Z
},
4 j" y4 u5 v6 a7 Q8 a; p {% C' i5 u; |6 }* C$ C* n; e
.active_low = 0,
& R: d3 j" Q( l" \9 x0 y .gpio = DA850_USER_LED1,
# F" e% C9 ~& o( O .name = "user_led1",) N& M) k& H; k4 O. L; f1 Z
.default_trigger = "default-on",6 ^+ Z$ ?; u, P D# _* ^$ O0 j
},7 a- p% z" j; | R
{
0 a& i5 V9 H) e/ q$ y1 u3 T .active_low = 0,
/ s9 O) y6 }- `$ V" ~. r/ Y. q! b% h .gpio = DA850_USER_LED2,* Q/ q4 H# x0 [8 ?6 m9 G. Q
.name = "user_led2",, a7 t& R& l4 ?, j! m
.default_trigger = "default-on",
0 M6 _5 e7 q! \: m* Y },
7 ~% E- `& p0 q. R3 H6 v {
d4 g' r6 _+ d4 T, } .active_low = 0,. _( S( W. q5 W0 [" i" N( L! ]
.gpio = DA850_USER_LED3," v7 W; c+ ^- K8 L M$ N& U6 z
.name = "user_led3",
# R" T7 v/ a- I7 |' o# @ O) y .default_trigger = "default-on",
# J" P" L* J% D7 l },
- z7 n& n5 ^' U, W};8 C. _% n3 e2 l6 S9 {* M7 B
3 w. Z( X, w" B" H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# ]! J% m" ^6 P% P5 ? .leds = da850_evm_tl_leds,
7 T3 v6 y& J0 b" c+ S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 G( x0 S" p! }" o
};
1 y8 l0 k) l( F# f$ G9 r' E+ u9 H" e+ l: y0 n0 C3 z
static void led_dev_release(struct device *dev)
: [. |. L1 h1 b% t% w{
% A+ f) |" {6 l- _! ]. y2 K};
, a; d* T' I9 Q0 d0 @1 T- ~4 k& S. j; V Z
static struct platform_device da850_evm_tl_leds_device = {) C3 S4 v) J( p+ F& L7 B5 D& G
.name = "leds-gpio",7 @5 E% f% C! g% Y: m! j: }' @( y
.id = 1,
/ h( I T2 P3 i$ ]' X0 q) C .dev = {
" v2 e0 b6 x; o9 V .platform_data = &da850_evm_tl_leds_pdata,
- d9 `# }, c/ D$ `- J3 A+ @/ F .release = led_dev_release,
" P' }% u6 ~- D9 v9 m6 r O7 R }
* x: f5 E7 \2 U4 E" b* s) u};8 j; t; n* O4 d$ E
8 @ s& a& [; [( ?
static int __init led_platform_init(void)
( I# K9 s1 L; C{
+ b; l& y p/ j, D0 N9 a int ret;' U l/ l' M8 ^. h ^1 K
#if 0& v& Z: x: s4 |/ E' L
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* g3 ~8 A V2 `9 v4 [ if (ret)
6 o& ?" k- [7 P2 B1 ~$ f6 H- c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( M( l. H" U2 s' N: a. o "%d\n", ret);
3 A# K9 o1 y9 Z7 y: C#endif0 \+ l& k; r Z$ {2 W$ T
ret = platform_device_register(&da850_evm_tl_leds_device);
* V) P) O- [0 h3 S8 Y; D if (ret)
7 n" v0 F, }' I4 T7 ] pr_warning("Could not register som GPIO expander LEDS");
+ ~9 A b- t! P else: d3 M% P+ B& u
printk(KERN_INFO "LED register sucessful!\n");6 G, R1 h+ Y1 j1 g* X0 @
: w* o9 w3 [! Z; K return ret; v( z |: {" l0 e$ Q9 j) \& \% L2 S$ D
}* u: \7 s9 t3 T' _( c
+ T0 g4 J1 J8 V" G5 h' }3 K
static void __exit led_platform_exit(void)7 a3 z/ b K6 m+ l# H
{* q" _, {# [4 b7 s
platform_device_unregister(&da850_evm_tl_leds_device);
- J9 L6 B8 q% e; T% w2 w- y, K! b; Z4 v( v4 y; W
printk(KERN_INFO "LED unregister!\n");
5 E7 t" e( S/ c/ \}1 J! K. e% y% I9 p( F
; }8 t! A Q+ I3 {8 N/ _
module_init(led_platform_init);
K( ~( C) p d$ d: Y& l% l7 Kmodule_exit(led_platform_exit);5 Z* p$ l+ \# U
/ e9 ^1 ^+ w2 c
MODULE_DESCRIPTION("Led platform driver");
$ v8 s! m0 U* L% v! j3 G( H dMODULE_AUTHOR("Tronlong");
# Z/ K' y+ b# `8 S8 x! JMODULE_LICENSE("GPL");
8 d- u3 R) _8 B: N- } j/ D$ {5 Q" L, m9 r' H B' }7 ]
|
|