|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 i# B' g! V6 M3 I/ o#include <linux/init.h>2 _; N% f' n7 \$ z
#include <linux/module.h>
3 B! g8 J2 g h% l1 ^, q#include <linux/kernel.h># x7 y3 Q6 F9 ~
#include <linux/types.h>
/ }1 d! N0 z4 @/ q#include <linux/gpio.h>
7 V0 z! Z+ C% {$ I7 L/ k* \8 ?9 j#include <linux/leds.h>
1 h- d. J$ t7 e) D5 d#include <linux/platform_device.h>$ M( S0 C. a' i; |( s6 X
! o* D! a3 i4 o4 [, m
#include <asm/mach-types.h>
* m6 y3 `$ `/ g2 L. e#include <asm/mach/arch.h>
( Y' U4 B1 P: v3 f$ w, ]4 U1 T#include <mach/da8xx.h>0 L2 e+ l' `3 H
#include <mach/mux.h>7 s* i( f' [& d& G8 D; V
% c4 o7 r: X+ W% Z/ k4 Y5 G5 I. X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 v: @( T/ o6 ]2 D) g0 p" h' j. r
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ M& F- C3 i: |( k) }9 Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% k# |8 y4 u; x! f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" ^5 K6 C' G( \6 N
) N f& p; L. \8 [" j/* assign the tl som board LED-GPIOs*/% v+ _* z( H1 k; d
static const short da850_evm_tl_user_led_pins[] = {) r. q( y: Y6 _7 J/ {' E8 o
/* These pins are definition at <mach/mux.h> file */& ~% \: K F, @! D( c. r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 c0 n1 J+ q# R
-1
0 k' D4 |$ F( Y- B/ e};, i6 {) O1 K! V' f- q* H1 U7 c
7 z1 e# [2 B1 zstatic struct gpio_led da850_evm_tl_leds[] = {
6 D" H1 W2 P# o7 ?; ? {
; U# {# i4 K4 e5 M( o; q9 W .active_low = 0,
+ ^) ~: J) i8 m$ {, x .gpio = DA850_USER_LED0,
+ L$ T& y! i6 e2 v7 e8 n .name = "user_led0",
/ U% Z* R! H8 C" ~/ y( V .default_trigger = "default-on",
& _1 I& b" p- {" u7 u5 o& R },
; p1 c6 [' d$ l3 I7 ~' }) Z$ i {$ W8 G: U5 B. t! f! Y$ r# q0 e
.active_low = 0,# t9 c- O6 y( x. O6 W1 p
.gpio = DA850_USER_LED1,
% w# W3 Q: i2 g8 O2 P' \) ]9 w$ J .name = "user_led1",
! \; Q5 D6 p. C) c% T- _- |: t .default_trigger = "default-on",
: S3 m8 H; P" R, ^ },
: V2 E; I' j( U$ `: A- z% C1 O- ^ {( {" d! V( n9 q' ~7 b4 N
.active_low = 0,
# d9 ]8 b+ s! F8 O .gpio = DA850_USER_LED2,1 b6 A+ }+ \) s2 c' d
.name = "user_led2",$ h: A5 ?3 s# v7 T
.default_trigger = "default-on",
. z! T* R% s9 ~+ h( O( K/ z },
0 A* c+ s; u1 Q9 b- g* E {
' c/ @8 {/ c! l; g) \, z .active_low = 0,
: B4 S _% Z: b- }/ c) R .gpio = DA850_USER_LED3,
& Y& [5 ~# o( [& n2 `, r. \: ? .name = "user_led3",
5 F! F7 ^4 y' g5 e, P3 N) u8 U% y .default_trigger = "default-on",
& d* A$ t* G+ b2 R% s" g1 { },
R3 u) w$ M: P z- n};+ m% H. h9 c$ R
9 I9 I$ N- |1 e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! R% @* L! p6 L4 Z. ] .leds = da850_evm_tl_leds,9 U$ \: a6 W' u" V- `* A, L* ]7 D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; Z# }5 g! P* v9 u1 a B# _};. @, @; I+ F# a; F9 r& j8 O
1 o B9 `, d& ~# n! `/ j
static void led_dev_release(struct device *dev)
) C# E. K2 N" ~2 L1 h{
( D) C2 m. n; [3 Z' D};2 |0 r6 S/ }% m! T: o2 p! V
O7 T% q. @5 C; U$ `$ s9 Sstatic struct platform_device da850_evm_tl_leds_device = {5 W) X( z8 n$ H' N
.name = "leds-gpio",
2 n9 M7 W+ N7 N% ?3 Y# _ .id = 1,5 U- q% h" R; r# ^7 K
.dev = {
+ E [7 E$ o# @4 ` .platform_data = &da850_evm_tl_leds_pdata,
$ M* w) w& h; N5 t. e. Z .release = led_dev_release,7 S! p, E, l6 O
}
9 f9 |# Y& a$ |9 G+ s* D; t- j8 U};
) H3 H+ D. c5 U. s! ~
% X' c; @0 |# G" g, }static int __init led_platform_init(void)
5 ]" f: C9 R, U7 w5 ^, p& p{4 V' l/ p# r- @, G5 ~7 v
int ret;' L2 M; l4 e9 _4 V% ]6 z3 [4 ~5 P+ C
#if 0
0 {" j- a/ s0 p ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* l, b$ I. B7 p7 L2 v) e. n
if (ret)
) A1 u: t6 a3 a pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- N3 [7 c R9 w; b/ p$ B% K' S8 E8 e
"%d\n", ret);
3 |/ u V# E9 p4 J& U& b#endif
% V9 U5 }, U( X' w ret = platform_device_register(&da850_evm_tl_leds_device);; n+ C$ V( l7 n% H4 ]
if (ret)5 p K5 l5 }$ p9 u- j
pr_warning("Could not register som GPIO expander LEDS");2 @7 D* X. y p1 V; a1 c
else. V" O0 p% G! w0 r/ a' e
printk(KERN_INFO "LED register sucessful!\n");
" h$ m9 x0 j1 D7 N' i
. y5 h+ p9 ]9 k. F" R return ret;
" Y5 f g4 X- U1 s5 V}
4 ^5 o4 t9 n' q# W! X; P8 w/ `: w( u. E. Q
static void __exit led_platform_exit(void)
# ^) o' `( E" x" Z* k- n{
, G1 ^% y/ t1 n5 I) Q platform_device_unregister(&da850_evm_tl_leds_device);
$ C6 d/ q0 R) ^% N J+ b) B/ F8 u% h& O$ U
printk(KERN_INFO "LED unregister!\n");
8 S- h7 f/ w+ F' G+ q* i7 D}
9 t3 i( k' F" q4 Z* M: P# ~4 [! M; Y$ y5 J( F3 P
module_init(led_platform_init);
+ a5 ~, U7 l4 `) imodule_exit(led_platform_exit);$ p) h1 X% B- F$ w5 @0 b8 I8 y& w7 `
3 w/ }% `% z6 p# n* Z0 H
MODULE_DESCRIPTION("Led platform driver");5 N a7 j/ M4 s+ e1 `% j
MODULE_AUTHOR("Tronlong");
; I; q( f3 H, Q& o7 ]* C% uMODULE_LICENSE("GPL");
`0 [2 h3 C: W0 s c
& h1 A; a1 b% ~8 `8 ` |
|